diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-04 16:44:15 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-04 16:44:15 +0000 |
| commit | 7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc (patch) | |
| tree | c6fd23b598f3994eddb18cb1c0f2e8d95ff054fa /wp-admin | |
| parent | f650f48c048bfbbb2ae702b6425d87e39358d748 (diff) | |
| download | wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.gz wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.xz wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.zip | |
Merged with WordPress 2.5, unstable, only for testing
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1218 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin')
147 files changed, 9152 insertions, 5947 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 013e375..13a869e 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1,61 +1,91 @@ <?php +define('DOING_AJAX', true); + require_once('../wp-config.php'); require_once('includes/admin.php'); -define('DOING_AJAX', true); - -check_ajax_referer(); if ( !is_user_logged_in() ) die('-1'); -function get_out_now() { exit; } -add_action( 'shutdown', 'get_out_now', -1 ); - -function wp_ajax_meta_row( $pid, $mid, $key, $value ) { - $value = attribute_escape($value); - $key_js = addslashes(wp_specialchars($key, 'double')); - $key = attribute_escape($key); - $r .= "<tr id='meta-$mid'><td valign='top'>"; - $r .= "<input name='meta[$mid][key]' tabindex='6' onkeypress='return killSubmit(\"theList.ajaxUpdater('meta','meta-$mid');\",event);' type='text' size='20' value='$key' />"; - $r .= "</td><td><textarea name='meta[$mid][value]' tabindex='6' rows='2' cols='30'>$value</textarea></td><td align='center'>"; - $r .= "<input name='updatemeta' type='button' class='updatemeta' tabindex='6' value='".attribute_escape(__('Update'))."' onclick='return theList.ajaxUpdater('meta','meta-$mid');' /><br />"; - $r .= "<input name='deletemeta[$mid]' type='submit' onclick=\"return deleteSomething( 'meta', $mid, '"; - $r .= js_escape(sprintf(__("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop."), $key_js)); - $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__('Delete'))."' /></td></tr>"; - return $r; +if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) { + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $s = $_GET['q']; // is this slashed already? + + if ( strstr( $s, ',' ) ) + die; // it's a multiple tag insert, we won't find anything + $results = $wpdb->get_col( "SELECT name FROM $wpdb->terms WHERE name LIKE ('%$s%')" ); + echo join( $results, "\n" ); + die; } -$id = (int) $_POST['id']; -switch ( $_POST['action'] ) : +$id = isset($_POST['id'])? (int) $_POST['id'] : 0; +switch ( $action = $_POST['action'] ) : case 'delete-comment' : + check_ajax_referer( "delete-comment_$id" ); 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'); + if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) + $r = wp_set_comment_status( $comment->comment_ID, 'spam' ); + else + $r = wp_delete_comment( $comment->comment_ID ); + + die( $r ? '1' : '0' ); break; -case 'delete-comment-as-spam' : - if ( !$comment = get_comment( $id ) ) - die('0'); - if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) +case 'delete-cat' : + check_ajax_referer( "delete-category_$id" ); + if ( !current_user_can( 'manage_categories' ) ) die('-1'); - if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) + if ( wp_delete_category( $id ) ) die('1'); else die('0'); break; -case 'delete-cat' : +case 'delete-tag' : + check_ajax_referer( "delete-tag_$id" ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); - if ( wp_delete_category( $id ) ) + if ( wp_delete_term($id, 'post_tag')) die('1'); else die('0'); break; +case 'delete-link-cat' : + check_ajax_referer( "delete-link-category_$id" ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + $cat_name = get_term_field('name', $id, 'link_category'); + + // Don't delete the default cats. + if ( $id == get_option('default_link_category') ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $id, + 'data' => new WP_Error( 'default-link-cat', sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name) ) + ) ); + $x->send(); + } + + $r = wp_delete_term($id, 'link_category'); + if ( !$r ) + die('0'); + if ( is_wp_error($r) ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $id, + 'data' => $r + ) ); + $x->send(); + } + die('1'); + break; case 'delete-link' : + check_ajax_referer( "delete-bookmark_$id" ); if ( !current_user_can( 'manage_links' ) ) die('-1'); @@ -64,6 +94,7 @@ case 'delete-link' : else die('0'); break; case 'delete-meta' : + check_ajax_referer( "delete-meta_$id" ); if ( !$meta = get_post_meta_by_id( $id ) ) die('0'); if ( !current_user_can( 'edit_post', $meta->post_id ) ) @@ -73,14 +104,17 @@ case 'delete-meta' : die('0'); break; case 'delete-post' : + check_ajax_referer( "{$action}_$id" ); if ( !current_user_can( 'delete_post', $id ) ) die('-1'); if ( wp_delete_post( $id ) ) die('1'); - else die('0'); + else + die('0'); break; case 'delete-page' : + check_ajax_referer( "{$action}_$id" ); if ( !current_user_can( 'delete_page', $id ) ) die('-1'); @@ -97,88 +131,224 @@ case 'dim-comment' : die('-1'); if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { + check_ajax_referer( "approve-comment_$id" ); if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) die('1'); } else { + check_ajax_referer( "unapprove-comment_$id" ); if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) die('1'); } die('0'); break; case 'add-category' : // On the Fly + check_ajax_referer( $action ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); $names = explode(',', $_POST['newcat']); + if ( 0 > $parent = (int) $_POST['newcat_parent'] ) + $parent = 0; + $post_category = isset($_POST['post_category'])? (array) $_POST['post_category'] : array(); + $checked_categories = array_map( 'absint', (array) $post_category ); + $x = new WP_Ajax_Response(); 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)); + $category_nicename = sanitize_title($cat_name); + if ( '' === $category_nicename ) + continue; + $cat_id = wp_create_category( $cat_name, $parent ); + $checked_categories[] = $cat_id; + if ( $parent ) // Do these all at once in a second + continue; + $category = get_category( $cat_id ); + $checked_categories[] = $cat_id; + ob_start(); + dropdown_categories( 0, $category ); + $data = ob_get_contents(); + ob_end_clean(); $x->add( array( 'what' => 'category', 'id' => $cat_id, - 'data' => "<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>" + 'data' => $data, + 'position' => -1 ) ); } + if ( $parent ) { // Foncy - replace the parent and all its children + $parent = get_category( $parent ); + ob_start(); + dropdown_categories( 0, $parent ); + $data = ob_get_contents(); + ob_end_clean(); + $x->add( array( + 'what' => 'category', + 'id' => $parent->term_id, + 'old_id' => $parent->term_id, + 'data' => $data, + 'position' => -1 + ) ); + + } $x->send(); break; case 'add-link-category' : // On the Fly + check_ajax_referer( $action ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); $names = explode(',', $_POST['newcat']); $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim($cat_name); - if ( !$slug = sanitize_title($cat_name) ) - die('0'); + $slug = sanitize_title($cat_name); + if ( '' === $slug ) + continue; if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { $cat_id = wp_insert_term( $cat_name, 'link_category' ); - $cat_id = $cat_id['term_id']; } + $cat_id = $cat_id['term_id']; $cat_name = wp_specialchars(stripslashes($cat_name)); $x->add( array( 'what' => 'link-category', 'id' => $cat_id, - 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>" + 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>", + 'position' => -1 ) ); } $x->send(); break; case 'add-cat' : // From Manage->Categories + check_ajax_referer( 'add-category' ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); - if ( !$cat = wp_insert_category( $_POST ) ) - die('0'); - if ( !$cat = get_category( $cat ) ) + + if ( '' === trim($_POST['cat_name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + + if ( category_exists( trim( $_POST['cat_name'] ) ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ), + ) ); + $x->send(); + } + + $cat = wp_insert_category( $_POST, true ); + + if ( is_wp_error($cat) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => $cat + ) ); + $x->send(); + } + + if ( !$cat || (!$cat = get_category( $cat )) ) die('0'); + $level = 0; - $cat_full_name = $cat->cat_name; + $cat_full_name = $cat->name; $_cat = $cat; - while ( $_cat->category_parent ) { - $_cat = get_category( $_cat->category_parent ); - $cat_full_name = $_cat->cat_name . ' — ' . $cat_full_name; + while ( $_cat->parent ) { + $_cat = get_category( $_cat->parent ); + $cat_full_name = $_cat->name . ' — ' . $cat_full_name; $level++; } $cat_full_name = attribute_escape($cat_full_name); $x = new WP_Ajax_Response( array( 'what' => 'cat', - 'id' => $cat->cat_ID, + 'id' => $cat->term_id, 'data' => _cat_row( $cat, $level, $cat_full_name ), - 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name)) + 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->term_id", $cat_full_name)) + ) ); + $x->send(); + break; +case 'add-link-cat' : // From Blogroll -> Categories + check_ajax_referer( 'add-link-category' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => new WP_Error( 'name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + + $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); + if ( is_wp_error( $r ) ) { + $x = new WP_AJAX_Response( array( + 'what' => 'link-cat', + 'id' => $r + ) ); + $x->send(); + } + + extract($r, EXTR_SKIP); + + if ( !$link_cat = link_cat_row( $term_id ) ) + die('0'); + + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => $term_id, + 'data' => $link_cat + ) ); + $x->send(); + break; +case 'add-tag' : // From Manage->Tags + check_ajax_referer( 'add-tag' ); + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => new WP_Error( 'name', __('You did not enter a tag name.') ) + ) ); + $x->send(); + } + + $tag = wp_insert_term($_POST['name'], 'post_tag', $_POST ); + + if ( is_wp_error($tag) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => $tag + ) ); + $x->send(); + } + + if ( !$tag || (!$tag = get_term( $tag['term_id'], 'post_tag' )) ) + die('0'); + + $tag_full_name = $tag->name; + $tag_full_name = attribute_escape($tag_full_name); + + $x = new WP_Ajax_Response( array( + 'what' => 'tag', + 'id' => $tag->term_id, + 'data' => _tag_row( $tag ), + 'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag <a href="#%s">%s</a> added' ), "tag-$tag->term_id", $tag_full_name)) ) ); $x->send(); break; case 'add-comment' : + check_ajax_referer( $action ); if ( !current_user_can( 'edit_post', $id ) ) die('-1'); $search = isset($_POST['s']) ? $_POST['s'] : false; - $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; + $start = isset($_POST['page']) ? intval($_POST['page']) * 25 - 1: 24; + $status = isset($_POST['comment_status']) ? $_POST['comment_status'] : false; + $mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail'; - list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); + list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1 ); if ( !$comments ) die('1'); @@ -186,7 +356,7 @@ case 'add-comment' : foreach ( (array) $comments as $comment ) { get_comment( $comment ); ob_start(); - _wp_comment_list_item( $comment->comment_ID ); + _wp_comment_row( $comment->comment_ID, $mode, false ); $comment_list_item = ob_get_contents(); ob_end_clean(); $x->add( array( @@ -198,96 +368,140 @@ case 'add-comment' : $x->send(); break; case 'add-meta' : - if ( !current_user_can( 'edit_post', $id ) ) - die('-1'); - if ( $id < 0 ) { - $now = current_time('timestamp', 1); - if ( $pid = wp_insert_post( array( - 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) - ) ) ) { - if ( is_wp_error( $pid ) ) - return $pid; - $mid = add_meta( $pid ); - } - else + check_ajax_referer( 'add-meta' ); + $c = 0; + $pid = (int) $_POST['post_id']; + if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { + if ( !current_user_can( 'edit_post', $pid ) ) + die('-1'); + if ( '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) + die('1'); + if ( $pid < 0 ) { + $now = current_time('timestamp', 1); + if ( $pid = wp_insert_post( array( + 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) + ) ) ) { + if ( is_wp_error( $pid ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'data' => $pid + ) ); + $x->send(); + } + $mid = add_meta( $pid ); + } else { + die('0'); + } + } else if ( !$mid = add_meta( $pid ) ) { die('0'); - } else if ( !$mid = add_meta( $id ) ) { - die('0'); - } - - $meta = get_post_meta_by_id( $mid ); - $key = $meta->meta_key; - $value = $meta->meta_value; - $pid = (int) $meta->post_id; + } - $x = new WP_Ajax_Response( array( - 'what' => 'meta', - 'id' => $mid, - 'data' => wp_ajax_meta_row( $pid, $mid, $key, $value ), - 'supplemental' => array('postid' => $pid) - ) ); - $x->send(); - 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 meta doesn't exist - if ( !current_user_can( 'edit_post', $meta->post_id ) ) - die('-1'); - if ( $u = update_meta( $mid, $key, $value ) ) { + $meta = get_post_meta_by_id( $mid ); + $pid = (int) $meta->post_id; + $meta = get_object_vars( $meta ); + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'id' => $mid, + 'data' => _list_meta_row( $meta, $c ), + 'position' => 1, + 'supplemental' => array('postid' => $pid) + ) ); + } else { + $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 meta doesn't exist + if ( !current_user_can( 'edit_post', $meta->post_id ) ) + die('-1'); + if ( !$u = update_meta( $mid, $key, $value ) ) + die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). $key = stripslashes($key); $value = stripslashes($value); $x = new WP_Ajax_Response( array( 'what' => 'meta', - 'id' => $mid, - 'data' => wp_ajax_meta_row( $meta->post_id, $mid, $key, $value ), + 'id' => $mid, 'old_id' => $mid, + 'data' => _list_meta_row( array( + 'meta_key' => $key, + 'meta_value' => $value, + 'meta_id' => $mid + ), $c ), + 'position' => 0, 'supplemental' => array('postid' => $meta->post_id) ) ); - $x->send(); } - die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). + $x->send(); break; case 'add-user' : + check_ajax_referer( $action ); if ( !current_user_can('edit_users') ) die('-1'); require_once(ABSPATH . WPINC . '/registration.php'); if ( !$user_id = add_user() ) die('0'); elseif ( is_wp_error( $user_id ) ) { - foreach( $user_id->get_error_messages() as $message ) - echo "<p>$message<p>"; - exit; + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id + ) ); + $x->send(); } $user_object = new WP_User( $user_id ); + $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, - 'data' => user_row( $user_object ), - 'supplemental' => array('show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login)) + 'data' => user_row( $user_object, '', $user_object->roles[0] ), + 'supplemental' => array( + 'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login), + 'role' => $user_object->roles[0] + ) ) ); $x->send(); break; case 'autosave' : // The name of this action is hardcoded in edit_post() - $_POST['post_content'] = $_POST['content']; - $_POST['post_excerpt'] = $_POST['excerpt']; + $nonce_age = check_ajax_referer( 'autosave', 'autosavenonce'); + global $current_user; + $_POST['post_status'] = 'draft'; $_POST['post_category'] = explode(",", $_POST['catslist']); + $_POST['tags_input'] = explode(",", $_POST['tags_input']); if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) unset($_POST['post_category']); + $do_autosave = (bool) $_POST['autosave']; + $do_lock = true; + + $data = ''; + $message = sprintf( __('Draft Saved at %s.'), date( __('g:i:s a'), current_time( 'timestamp', true ) ) ); + + $supplemental = array(); + + $id = 0; if($_POST['post_ID'] < 0) { $_POST['temp_ID'] = $_POST['post_ID']; - $id = wp_write_post(); - if( is_wp_error($id) ) - die($id->get_error_message()); - else - die("$id"); + if ( $do_autosave ) { + $id = wp_write_post(); + $data = $message; + } } else { $post_ID = (int) $_POST['post_ID']; $_POST['ID'] = $post_ID; $post = get_post($post_ID); + + if ( $last = wp_check_post_lock( $post->ID ) ) { + $do_autosave = $do_lock = false; + + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); + $data = new WP_Error( 'locked', sprintf( + $_POST['post_type'] == 'page' ? __( 'Autosave disabled: %s is currently editing this page.' ) : __( 'Autosave disabled: %s is currently editing this post.' ), + wp_specialchars( $last_user_name ) + ) ); + + $supplemental['disable_autosave'] = 'disable'; + } + if ( 'page' == $post->post_type ) { if ( !current_user_can('edit_page', $post_ID) ) die(__('You are not allowed to edit this page.')); @@ -295,11 +509,40 @@ case 'autosave' : // The name of this action is hardcoded in edit_post() if ( !current_user_can('edit_post', $post_ID) ) die(__('You are not allowed to edit this post.')); } - wp_update_post($_POST); + if ( $do_autosave ) { + $id = edit_post(); + $data = $message; + } else { + $id = $post->ID; + } } - die('0'); -break; + + if ( $do_lock && $id && is_numeric($id) ) + wp_set_post_lock( $id ); + + if ( $nonce_age == 2 ) { + $supplemental['replace-autosavenonce'] = wp_create_nonce('autosave'); + $supplemental['replace-getpermalinknonce'] = wp_create_nonce('getpermalink'); + $supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink'); + $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes'); + if ( $id ) { + if ( $_POST['post_type'] == 'post' ) + $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id); + elseif ( $_POST['post_type'] == 'page' ) + $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id); + } + } + + $x = new WP_Ajax_Response( array( + 'what' => 'autosave', + 'id' => $id, + 'data' => $id ? $data : '', + 'supplemental' => $supplemental + ) ); + $x->send(); + break; case 'autosave-generate-nonces' : + check_ajax_referer( 'autosave', 'autosavenonce' ); $ID = (int) $_POST['post_ID']; if($_POST['post_type'] == 'post') { if(current_user_can('edit_post', $ID)) @@ -312,6 +555,30 @@ case 'autosave-generate-nonces' : } die('0'); break; +case 'closed-postboxes' : + check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); + $closed = isset( $_POST['closed'] )? $_POST['closed'] : ''; + $closed = explode( ',', $_POST['closed'] ); + $page = isset( $_POST['page'] )? $_POST['page'] : ''; + if ( !preg_match( '/^[a-z-]+$/', $page ) ) { + die(-1); + } + if (!is_array($closed)) break; + $current_user = wp_get_current_user(); + update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed); +break; +case 'get-permalink': + check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + die(add_query_arg(array('preview' => 'true'), get_permalink($post_id))); +break; +case 'sample-permalink': + check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; + $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : ''; + die(get_sample_permalink_html($post_id, $title, $slug)); +break; default : do_action( 'wp_ajax_' . $_POST['action'] ); die('0'); diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index 95e1cdc..889c2f9 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -1,9 +1,12 @@ - +</div><!-- wpbody --> +</div><!-- wpcontent --> +</div><!-- wpwrap --> <div id="footer"> -<?php -$footer_text = '<p>' . __('Thank you for creating with <a href="http://mu.wordpress.org/">WordPress MU</a>') . ' | ' . __('<a href="http://mu.wordpress.org/docs/">Documentation</a>') . '</p>'; +<p><?php +do_action('in_admin_footer', ''); +$footer_text = __('Thank you for creating with <a href="http://mu.wordpress.org/">WordPress MU</a>') . ' | ' . __('<a href="http://mu.wordpress.org/docs/">Documentation</a>'); echo apply_filters( 'admin_footer_text', $footer_text ); -?> +?></p> </div> <?php do_action('admin_footer', ''); ?> <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 9064d19..4a0d327 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1,4 +1,5 @@ <?php // Deprecated. Use includes/admin.php. +_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/admin.php' ); require_once(ABSPATH . 'wp-admin/includes/admin.php'); ?> diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index a75fe7b..0185a98 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -2,13 +2,23 @@ @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); if (!isset($_GET["page"])) require_once('admin.php'); if ( $editing ) { - wp_enqueue_script( array('dbx-admin-key?pagenow=' . attribute_escape($pagenow),'admin-custom-fields') ); - if ( current_user_can('manage_categories') ) - wp_enqueue_script( 'ajaxcat' ); if ( user_can_richedit() ) wp_enqueue_script( 'wp_tiny_mce' ); } +$min_width_pages = array( 'post.php', 'post-new.php', 'page.php', 'page-new.php', 'widgets.php', 'comment.php', 'link.php' ); +$the_current_page = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']); +$ie6_no_scrollbar = true; + +function add_minwidth($c) { + return $c . 'minwidth '; +} + +if ( in_array( $the_current_page, $min_width_pages ) ) { + $ie6_no_scrollbar = false; + add_filter( 'admin_body_class', 'add_minwidth' ); +} + get_admin_page_title(); ?> @@ -17,13 +27,21 @@ get_admin_page_title(); <head> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> <title><?php bloginfo('name') ?> › <?php echo wp_specialchars( strip_tags( $title ) ); ?> — WordPress</title> -<?php wp_admin_css(); ?> +<?php +wp_admin_css( 'css/global' ); +wp_admin_css(); +wp_admin_css( 'css/colors' ); +?> +<!--[if gte IE 6]> +<?php wp_admin_css( 'css/ie' ); +?> +<![endif]--> <script type="text/javascript"> //<![CDATA[ -function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} +addLoadEvent = function(func) {if (typeof jQuery != "undefined") jQuery(document).ready(func); else if (typeof wpOnload!='function'){wpOnload=func;} else {var oldonload=wpOnload; wpOnload=function(){oldonload();func();}}}; //]]> </script> -<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?> +<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') && $ie6_no_scrollbar ) : ?> <style type="text/css">* html { overflow-x: hidden; }</style> <?php endif; if ( isset($page_hook) ) @@ -40,10 +58,12 @@ do_action('admin_head'); ?> </head> <body class="wp-admin <?php echo apply_filters( 'admin_body_class', '' ); ?>"> +<div id="wpwrap"> +<div id="wpcontent"> <div id="wphead"> -<h1><?php bloginfo('name'); ?> <span id="viewsite">(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span></h1> +<h1><?php bloginfo('name'); ?><span id="viewsite"><a href="<?php echo trailingslashit( get_option('home') ); ?>"><?php _e('Visit Site') ?></a></span></h1> </div> -<div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Profile'); ?></a>] </p></div> +<div id="user_info"><p><?php printf(__('Howdy, <a href="%1$s">%2$s</a>!'), 'profile.php', $user_identity) ?> | <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a> | <?php _e('<a href="http://codex.wordpress.org/">Help</a>') ?> | <?php _e('<a href="http://wordpress.org/support/">Forums</a>') ?></p></div> <?php require(ABSPATH . 'wp-admin/menu-header.php'); @@ -52,3 +72,4 @@ if ( $parent_file == 'options-general.php' ) { require(ABSPATH . 'wp-admin/options-head.php'); } ?> +<div id="wpbody"> diff --git a/wp-admin/admin.php b/wp-admin/admin.php index aaa8efa..50f3c30 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -25,8 +25,6 @@ nocache_headers(); update_category_cache(); -wp_get_current_user(); - $posts_per_page = get_option('posts_per_page'); $what_to_show = get_option('what_to_show'); $date_format = get_option('date_format'); @@ -34,7 +32,11 @@ $time_format = get_option('time_format'); wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback')); -wp_enqueue_script( 'fat' ); +wp_admin_css_color('classic', __('Classic'), get_option( 'siteurl' ) . "/wp-admin/css/colors-classic.css", array('#07273E', '#14568A', '#D54E21', '#2683AE')); +wp_admin_css_color('fresh', __('Fresh'), get_option( 'siteurl' ) . "/wp-admin/css/colors-fresh.css", array('#464646', '#CEE1EF', '#D54E21', '#2683AE')); + +wp_enqueue_script( 'common' ); +wp_enqueue_script( 'jquery-color' ); $editing = false; @@ -45,6 +47,8 @@ if (isset($_GET['page'])) { require(ABSPATH . 'wp-admin/menu.php'); +do_action('admin_init'); + // Handle plugin admin pages. if (isset($plugin_page)) { $page_hook = get_plugin_page_hook($plugin_page, $pagenow); diff --git a/wp-admin/bookmarklet.php b/wp-admin/bookmarklet.php index fca99e1..8618458 100644 --- a/wp-admin/bookmarklet.php +++ b/wp-admin/bookmarklet.php @@ -51,7 +51,10 @@ if ( !empty($content) ) { <head> <title><?php bloginfo('name') ?> › Bookmarklet — WordPress</title> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> -<?php wp_admin_css(); ?> +<?php +wp_admin_css( 'css/global' ); +wp_admin_css(); +?> <style type="text/css"> <!-- diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 59ff4eb..945da0c 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -6,6 +6,9 @@ $parent_file = 'edit.php'; wp_reset_vars(array('action', 'cat')); +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) + $action = 'bulk-delete'; + switch($action) { case 'addcat': @@ -36,9 +39,6 @@ case 'delete': if ( $cat_ID == get_option('default_category') ) wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); - if ( $cat_ID == get_option('default_link_category') ) - wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one for links"), $cat_name)); - wp_delete_category($cat_ID); wp_redirect('categories.php?message=2'); @@ -46,6 +46,29 @@ case 'delete': break; +case 'bulk-delete': + check_admin_referer('bulk-categories'); + + if ( !current_user_can('manage_categories') ) + wp_die( __('You are not allowed to delete categories.') ); + + foreach ( (array) $_GET['delete'] as $cat_ID ) { + $cat_name = get_catname($cat_ID); + + // Don't delete the default cats. + if ( $cat_ID == get_option('default_category') ) + wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); + + wp_delete_category($cat_ID); + } + + $sendback = wp_get_referer(); + $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); + + wp_redirect($sendback); + exit(); + +break; case 'edit': require_once ('admin-header.php'); @@ -72,7 +95,14 @@ break; default: +if ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; +} + wp_enqueue_script( 'admin-categories' ); +wp_enqueue_script('admin-forms'); + require_once ('admin-header.php'); $messages[1] = __('Category added.'); @@ -84,30 +114,57 @@ $messages[5] = __('Category not updated.'); <?php if (isset($_GET['message'])) : ?> <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> -<?php endif; ?> +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); +endif; ?> <div class="wrap"> +<form id="posts-filter" action="" method="get"> <?php if ( current_user_can('manage_categories') ) : ?> - <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2> + <h2><?php printf(__('Manage Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2> <?php else : ?> - <h2><?php _e('Categories') ?> </h2> + <h2><?php _e('Manage Categories') ?> </h2> <?php endif; ?> + +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" /> + <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" /> +</p> + +<br class="clear" /> + +<div class="tablenav"> + +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php wp_nonce_field('bulk-categories'); ?> +</div> + +<br class="clear" /> +</div> + +<br class="clear" /> + <table class="widefat"> <thead> <tr> - <th scope="col" style="text-align: center"><?php _e('ID') ?></th> + <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> <th scope="col"><?php _e('Name') ?></th> <th scope="col"><?php _e('Description') ?></th> - <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th> - <th colspan="2" style="text-align: center"><?php _e('Action') ?></th> + <th scope="col" class="num"><?php _e('Posts') ?></th> </tr> </thead> - <tbody id="the-list"> + <tbody id="the-list" class="list:cat"> <?php cat_rows(); ?> </tbody> </table> +</form> + +<div class="tablenav"> +<br class="clear" /> +</div> +<br class="clear" /> </div> diff --git a/wp-admin/comment.php b/wp-admin/comment.php index eee6a12..514be26 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -4,70 +4,86 @@ require_once('admin.php'); $parent_file = 'edit-comments.php'; $submenu_file = 'edit-comments.php'; -wp_reset_vars(array('action')); +wp_reset_vars( array('action') ); if ( isset( $_POST['deletecomment'] ) ) $action = 'deletecomment'; -switch($action) { -case 'editcomment': +function comment_footer_die( $msg ) { // $msg is assumed to contain HTML and be sanitized + echo "<div class='wrap'><p>$msg</p></div>"; + include('admin-footer.php'); + die; +} + +switch( $action ) { + +case 'editcomment' : $title = __('Edit Comment'); - require_once ('admin-header.php'); + wp_enqueue_script('comment'); + //wp_enqueue_script('thickbox'); + require_once('admin-header.php'); - $comment = (int) $_GET['c']; + $comment_id = absint( $_GET['c'] ); - if ( ! $comment = get_comment($comment) ) - wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)')); + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') ); if ( !current_user_can('edit_post', $comment->comment_post_ID) ) - wp_die( __('You are not allowed to edit comments on this post.') ); + comment_footer_die( __('You are not allowed to edit comments on this post.') ); - $comment = get_comment_to_edit($comment); + $comment = get_comment_to_edit( $comment_id ); include('edit-form-comment.php'); break; -case 'cdc': -case 'mac': +case 'cdc' : +case 'mac' : - require_once('./admin-header.php'); + require_once('admin-header.php'); - $comment = (int) $_GET['c']; + $comment_id = absint( $_GET['c'] ); $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment'; $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_'; - $nonce_action .= $comment; + $nonce_action .= $comment_id; - if ( ! $comment = get_comment_to_edit($comment) ) - wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php')); + if ( !$comment = get_comment_to_edit( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); - if ( !current_user_can('edit_post', $comment->comment_post_ID) ) - wp_die( 'cdc' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + comment_footer_die( 'cdc' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); ?> <div class='wrap'> <div class="narrow"> -<?php if ( 'spam' == $_GET['dt'] ) { ?> -<p><?php echo '<strong>'.__('Caution:').'</strong> '.__('You are about to mark the following comment as spam:'); ?></p> -<?php } elseif ( 'cdc' == $action ) { ?> -<p><?php echo '<strong>'.__('Caution:').'</strong> '.__('You are about to delete the following comment:'); ?></p> -<?php } else { ?> -<p><?php echo '<strong>'.__('Caution:').'</strong> '.__('You are about to approve the following comment:'); ?></p> -<?php } ?> +<?php +if ( 'spam' == $_GET['dt'] ) { + $caution_msg = __('You are about to mark the following comment as spam:'); + $button = __('Spam Comment'); +} elseif ( 'cdc' == $action ) { + $caution_msg = __('You are about to delete the following comment:'); + $button = __('Delete Comment'); +} else { + $caution_msg = __('You are about to approve the following comment:'); + $button = __('Approve Comment'); +} +?> + +<p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> <p><?php _e('Are you sure you want to do that?'); ?></p> -<form action='<?php echo get_option('siteurl'); ?>/wp-admin/comment.php' method='get'> +<form action='comment.php' method='get'> <table width="100%"> <tr> -<td><input type='button' value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td> -<td align="right"><input type='submit' value='<?php _e('Yes'); ?>' /></td> +<td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td> +<td class="textright"><input type='submit' class="button" value='<?php echo $button; ?>' /></td> </tr> </table> -<?php wp_nonce_field($nonce_action); ?> +<?php wp_nonce_field( $nonce_action ); ?> <input type='hidden' name='action' value='<?php echo $formaction; ?>' /> <?php if ( 'spam' == $_GET['dt'] ) { ?> <input type='hidden' name='dt' value='spam' /> @@ -77,25 +93,25 @@ case 'mac': <input type='hidden' name='noredir' value='1' /> </form> -<table class="editform" cellpadding="5"> +<table class="form-table" cellpadding="5"> <tr class="alt"> -<th scope="row"><?php _e('Author:'); ?></th> +<th scope="row"><?php _e('Author'); ?></th> <td><?php echo $comment->comment_author; ?></td> </tr> <?php if ( $comment->comment_author_email ) { ?> <tr> -<th scope="row"><?php _e('E-mail:'); ?></th> +<th scope="row"><?php _e('E-mail'); ?></th> <td><?php echo $comment->comment_author_email; ?></td> </tr> <?php } ?> <?php if ( $comment->comment_author_url ) { ?> <tr> -<th scope="row"><?php _e('URL:'); ?></th> +<th scope="row"><?php _e('URL'); ?></th> <td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td> </tr> <?php } ?> <tr> -<th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th> +<th scope="row" valign="top"><?php _e('Comment'); ?></th> <td><?php echo $comment->comment_content; ?></td> </tr> </table> @@ -105,107 +121,108 @@ case 'mac': <?php break; -case 'deletecomment': - $comment = (int) $_REQUEST['c']; - check_admin_referer('delete-comment_' . $comment); +case 'deletecomment' : + $comment_id = absint( $_REQUEST['c'] ); + check_admin_referer( 'delete-comment_' . $comment_id ); - if ( isset($_REQUEST['noredir']) ) { + if ( isset( $_REQUEST['noredir'] ) ) $noredir = true; - } else { + else $noredir = false; - } - if ( ! $comment = get_comment($comment) ) - wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php')); + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') ); - if ( !current_user_can('edit_post', $comment->comment_post_ID) ) - wp_die( __('You are not allowed to edit comments on this post.') ); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + comment_footer_die( __('You are not allowed to edit comments on this post.') ); if ( 'spam' == $_REQUEST['dt'] ) - wp_set_comment_status($comment->comment_ID, 'spam'); + wp_set_comment_status( $comment->comment_ID, 'spam' ); else - wp_delete_comment($comment->comment_ID); + wp_delete_comment( $comment->comment_ID ); - if ((wp_get_referer() != '') && (false == $noredir)) { - wp_redirect(wp_get_referer()); - } else { - wp_redirect(get_option('siteurl') .'/wp-admin/edit-comments.php'); - } - exit(); + if ( '' != wp_get_referer() && false == $noredir ) + wp_redirect( wp_get_referer() ); + else + wp_redirect( get_option('siteurl') . '/wp-admin/edit-comments.php' ); + + die; break; -case 'unapprovecomment': - $comment = (int) $_GET['c']; - check_admin_referer('unapprove-comment_' . $comment); +case 'unapprovecomment' : + $comment_id = absint( $_GET['c'] ); + check_admin_referer( 'unapprove-comment_' . $comment_id ); - if (isset($_GET['noredir'])) { + if ( isset( $_GET['noredir'] ) ) $noredir = true; - } else { + else $noredir = false; - } - if ( ! $comment = get_comment($comment) ) - wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php')); + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); - if ( !current_user_can('edit_post', $comment->comment_post_ID) ) - wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') ); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') ); - wp_set_comment_status($comment->comment_ID, "hold"); + wp_set_comment_status( $comment->comment_ID, 'hold' ); + + if ( '' != wp_get_referer() && false == $noredir ) + wp_redirect( wp_get_referer() ); + else + wp_redirect( get_option('siteurl') . '/wp-admin/edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments' ); - if ((wp_get_referer() != "") && (false == $noredir)) { - wp_redirect(wp_get_referer()); - } else { - wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p=' . (int) $comment->comment_post_ID.'&c=1#comments'); - } exit(); break; -case 'approvecomment': - $comment = (int) $_GET['c']; - check_admin_referer('approve-comment_' . $comment); +case 'approvecomment' : + $comment_id = absint( $_GET['c'] ); + check_admin_referer( 'approve-comment_' . $comment_id ); - if (isset($_GET['noredir'])) { + if ( isset( $_GET['noredir'] ) ) $noredir = true; - } else { + else $noredir = false; - } - if ( ! $comment = get_comment($comment) ) - wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php')); + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); if ( !current_user_can('edit_post', $comment->comment_post_ID) ) - wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); + comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); - wp_set_comment_status($comment->comment_ID, "approve"); - if (get_option("comments_notify") == true) { - wp_notify_postauthor($comment->comment_ID); - } + wp_set_comment_status( $comment->comment_ID, 'approve' ); + if ( true == get_option('comments_notify') ) + wp_notify_postauthor( $comment->comment_ID ); + + + if ( '' != wp_get_referer() && false == $noredir ) + wp_redirect( wp_get_referer() ); + else + wp_redirect( get_option('siteurl') . '/wp-admin/edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments' ); - if ((wp_get_referer() != "") && (false == $noredir)) { - wp_redirect(wp_get_referer()); - } else { - wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p=' . (int) $comment->comment_post_ID.'&c=1#comments'); - } exit(); break; -case 'editedcomment': +case 'editedcomment' : - $comment_ID = (int) $_POST['comment_ID']; - $comment_post_ID = (int) $_POST['comment_post_id']; + $comment_id = absint( $_POST['comment_ID'] ); + $comment_post_id = absint( $_POST['comment_post_id'] ); - check_admin_referer('update-comment_' . $comment_ID); + check_admin_referer( 'update-comment_' . $comment_id ); edit_comment(); - $location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID; - $location = apply_filters('comment_edit_redirect', $location, $comment_ID); - wp_redirect($location); + $location = ( empty( $_POST['referredby'] ) ? "edit.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; + $location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); + wp_redirect( $location ); + exit(); break; + default: + wp_die( __('Unknown action.') ); break; + } // end switch include('admin-footer.php'); diff --git a/wp-admin/css/colors-classic-rtl.css b/wp-admin/css/colors-classic-rtl.css new file mode 100644 index 0000000..5d0d05c --- /dev/null +++ b/wp-admin/css/colors-classic-rtl.css @@ -0,0 +1,3 @@ +#poststuff .closed .togbox, #poststuff .togbox { +background-image: url(../images/toggle-arrow-rtl.gif) !important; +}
\ No newline at end of file diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index 4251f15..3a8f138 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -8,7 +8,7 @@ body { } body > #upload-menu { - border-bottom-style: #fff; + border-bottom-color: #fff; } div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, .widefat { @@ -31,7 +31,7 @@ input.disabled, textarea.disabled { background-color: #ccc; } -li.widget-list-control-item h4.widget-title a:hover, .submit a, #user_info a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a, +#user_info a:hover, li.widget-list-control-item h4.widget-title a:hover, .submit a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a, #dragHelper li.widget-list-control-item h4.widget-title a, #draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover { color: #fff; @@ -54,8 +54,8 @@ strong .post-com-count span { background-color: #2583ad; } -.button-secondary, #quicktags, #login form .submit input { - background-color: #83b4d5 !important; +.button-secondary, #login form .submit input { + background-color: #8ebddc !important; } ul#widget-list li.widget-list-item h4.widget-title { @@ -136,7 +136,7 @@ ul.widget-control-list .sorthelper { color: #999; } -#dashmenu a { +#dashmenu a, #user_info a { color: #88b4d7; } @@ -182,13 +182,13 @@ ul.widget-control-list .sorthelper { border-bottom-color: #dadada; } -.side-info ul { +.side-info ul, .widget-description { color: #666; } -.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input { +.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input, #edit-slug-buttons a.save { background-color: #e5e5e5; - color: #246; + color: #07273e; border-color: #a3a3a3; } @@ -196,16 +196,21 @@ ul.widget-control-list .sorthelper { border-color: #5396c5; } -.submit input:hover, .button:hover { +.submit input:hover, .button:hover, #edit-slug-buttons a.save:hover { border-color: #535353; } -.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #adminmenu a:hover, #sidemenu a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover { +.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover, #edit-slug-buttons a.save:hover { color: #d54e21; } +#adminmenu a:hover, #sidemenu a:hover { + color: #97c4d8; +} + .button-secondary:hover, #login form .submit input:hover { border-color: #328ab2; + background-color: #a6d2e5 !important; } .submitbox #autosave .error, ul.view-switch li.current a { @@ -296,7 +301,7 @@ ul.widget-control-list .sorthelper { /* Because we don't want visited on these links */ #adminmenu a.current, #sidemenu a.current { background-color: #fff; - border-color: #c6d9e9; + border-color: #07273e; border-bottom-color: #fff; color: #d54e21; font-weight: bold; @@ -323,7 +328,7 @@ ul.widget-control-list .sorthelper { #adminmenu, div#media-upload-header { background-color: #14568a; - border-bottom-color: #c6d9e9; + border-bottom-color: #07273e; } #currenttheme img { @@ -401,16 +406,24 @@ input.readonly { border-color: #319f52; } -#plugins .active, .checkbox, .side-info, #your-profile #rich_editing { +.checkbox, .side-info, #your-profile #rich_editing { background-color: #fff; } +#plugins .active { + background-color: #BBEEBB; +} + #plugins .togl { border-right-color: #ccc; } -#plugins tr, #the-comment-list .unapproved { - background-color: #f0f0f0; +#the-comment-list .unapproved { + background-color: #ffffe0; +} + +#plugins tr { + background-color: #fff; } #poststuff #editor-toolbar .active { @@ -448,7 +461,7 @@ input.readonly { #sidemenu a { background-color: #14568a; - border-bottom-color: #c6d9e9; + border-bottom-color: #07273e; border-top-color: #14568a; color: #cfebf6; } @@ -466,15 +479,11 @@ input.readonly { color: #666; } -#update-nag a:link, .plugin-update a:link { - color: #036; -} - #update-nag, .plugin-update { background-color: #fffeeb; border-bottom-color: #ccc; border-top-color: #ccc; - color: #cfebf6; + color: #555; } #upload-files a.file-link { @@ -520,13 +529,13 @@ input.readonly { } #wphead #viewsite a { - background-color: #94acc1; - color: white; - border-color: #94acc1; + background-color: #5488af; + color: #cfebf7; + border-color: #0b3d64; } #wphead #viewsite a:hover { - color: #246; + color: #07273e; } #wphead h1, #dashmenu a.current:hover { @@ -664,7 +673,7 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover } .wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, -.wp_themeSkin .mceMenu .mceMenuItemActive { +.wp_themeSkin .mceMenu .mceMenuItemActive, #quicktags { background-color: #83B4D5; } .wp_themeSkin td.mceMenuItemSeparator { @@ -699,3 +708,8 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover #poststuff #titlewrap { border-color: #ccc; } + +#tTips p#tTips_inside { + background-color: #ddd; + color: #333; +} diff --git a/wp-admin/css/colors-fresh-rtl.css b/wp-admin/css/colors-fresh-rtl.css new file mode 100644 index 0000000..5d0d05c --- /dev/null +++ b/wp-admin/css/colors-fresh-rtl.css @@ -0,0 +1,3 @@ +#poststuff .closed .togbox, #poststuff .togbox { +background-image: url(../images/toggle-arrow-rtl.gif) !important; +}
\ No newline at end of file diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index 823ba46..a0d45fb 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -8,7 +8,7 @@ body { } body > #upload-menu { - border-bottom-style: #fff; + border-bottom-color: #fff; } div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, .widefat { @@ -35,7 +35,7 @@ input.disabled, textarea.disabled { background-color: #ccc; } -li.widget-list-control-item h4.widget-title a:hover, .submit a, #user_info a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a, +#user_info a:hover, li.widget-list-control-item h4.widget-title a:hover, .submit a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a, #dragHelper li.widget-list-control-item h4.widget-title a, #draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover { color: #fff; @@ -132,7 +132,7 @@ ul.widget-control-list .sorthelper { color: #d54e21; } -.howto, .nonessential, #dashmenu a, #sidemenu, #edit-slug-box, .form-input-tip, #dashboard_primary span.rss-date, .subsubsub, #dashboard_secondary div.dashboard-widget-content ul li a cite { +#user_info, .howto, .nonessential, #dashmenu a, #sidemenu, #edit-slug-box, .form-input-tip, #dashboard_primary span.rss-date, .subsubsub, #dashboard_secondary div.dashboard-widget-content ul li a cite { color: #999; } @@ -178,21 +178,21 @@ ul.widget-control-list .sorthelper { border-bottom-color: #dadada; } -.side-info ul { +.side-info ul, .widget-description { color: #666; } -.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input { +.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input, #edit-slug-buttons a.save { background-color: #e5e5e5; color: #246; - border-color: #a3a3a3; + border-color: #80b5d0; } -.submit input:hover, .button:hover { +.submit input:hover, .button:hover, #edit-slug-buttons a.save:hover { border-color: #535353; } -.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #adminmenu a:hover, #sidemenu a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover { +.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #adminmenu a:hover, #sidemenu a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover, #edit-slug-buttons a.save:hover, #media-upload a.delete:hover { color: #d54e21; } @@ -342,10 +342,6 @@ input.readonly { color: #777; } -#edit-slug-buttons a.save { - background-color: #ebebeb; -} - #footer { background: url(../images/logo-ghost.png) #464646 no-repeat 20px 10px; color: #999; @@ -379,16 +375,24 @@ input.readonly { border-color: #319f52; } -#plugins .active, .checkbox, .side-info, #your-profile #rich_editing { +.checkbox, .side-info, #your-profile #rich_editing { background-color: #fff; } +#plugins .active { + background-color: #e7f7d3; +} + #plugins .togl { border-right-color: #ccc; } -#plugins tr, #the-comment-list .unapproved { - background-color: #f0f0f0; +#the-comment-list .unapproved { + background-color: #ffffe0; +} + +#plugins tr { + background-color: #fff; } #poststuff #editor-toolbar .active { @@ -443,10 +447,6 @@ input.readonly { color: #666; } -#update-nag a:link, .plugin-update a:link { - color: #036; -} - #update-nag, .plugin-update { background-color: #fffeeb; border-bottom-color: #ccc; @@ -484,7 +484,7 @@ input.readonly { border-top-color: #247fab; } -#user_info, .login #backtoblog a, .curtime { +.login #backtoblog a, .curtime, #user_info a { color: #ccc; } @@ -499,11 +499,11 @@ input.readonly { #wphead #viewsite a { background-color: #c6d9e9; color: #246; - border-color: #94acc1; + border-color: #80b5d0; } #wphead #viewsite a:hover { - border-color: #246; + border-color: #328ab2; } #wphead h1, #dashmenu a.current:hover, #login form input { @@ -678,4 +678,9 @@ div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover .curtime { color: #666; -}
\ No newline at end of file +} + +#tTips p#tTips_inside { + background-color: #ddd; + color: #333; +} diff --git a/wp-admin/css/dashboard-rtl.css b/wp-admin/css/dashboard-rtl.css new file mode 100644 index 0000000..29e59cf --- /dev/null +++ b/wp-admin/css/dashboard-rtl.css @@ -0,0 +1,62 @@ +#rightnow { + margin-left: 15px; +} + +#rightnow .reallynow span { + text-align: right; + float: right; +} + +#rightnow .reallynow a { + text-align: left; + float: left; + margin: 1px 0 0 6px; +} + +h3.dashboard-widget-title span { + text-align: right; + float: right; +} + +#dashboard-widgets .widget_rss ul li a { + float:right; + font-weight:bold; + margin:0pt 0pt 0.2em 0.5em; +} + +#dashboard-widgets .widget_rss ul li span.rss-date { + float: right; +} + +h3.dashboard-widget-title small { + text-align: left; + float: left; +} +div.dashboard-widget-content ul, +div.dashboard-widget-content ol, +div.dashboard-widget-content dl { + padding-left:0; + padding-right:15px; +} +div#dashboard-widgets-wrap +{ + margin-right:0; + margin-left:-10px; +} + +div.dashboard-widget { + margin-right:0; + margin-left:20px; +} + +#dashboard-widgets .widget_rss ul li span.rss-date { + float:right; +} +#dashboard-widgets .widget_rss ul li a { + float:right; + margin:0 0 0.2em 0.5em; +} +#dashboard_secondary div.dashboard-widget-content ul li a { + border-right:0 none; + border-left:1px solid #DADADA; +}
\ No newline at end of file diff --git a/wp-admin/css/dashboard.css b/wp-admin/css/dashboard.css index 003e8e3..eb07f86 100644 --- a/wp-admin/css/dashboard.css +++ b/wp-admin/css/dashboard.css @@ -64,7 +64,6 @@ div#dashboard-widgets-wrap { div#dashboard-widgets { width: 100%; - padding-right: 7px; /* (#rightnow margin-right) */ } div.dashboard-widget-holder { @@ -86,7 +85,7 @@ div.dashboard-widget-holder.full { } div.dashboard-widget-holder.double div.dashboard-widget { - height: 52em; + height: 54em; padding-bottom: 28px /* lame */ } diff --git a/wp-admin/css/global.css b/wp-admin/css/global.css index 5bd9e2f..926aa88 100644 --- a/wp-admin/css/global.css +++ b/wp-admin/css/global.css @@ -27,17 +27,59 @@ textarea, input, select { } .alignleft { float: left; } - .alignright { float: right; } +.textleft { text-align: left; } +.textright { text-align: right; } .clear { clear: both; height: 2px; } .hidden { display: none; } +h1 { + display: block; + font-size: 2em; + font-weight: bold; + margin: .67em 0; +} + +h2 { + display: block; + font-size: 1.5em; + font-weight: bold; + margin: .83em 0; +} + +h3 { + display: block; + font-size: 1.17em; + font-weight: bold; + margin: 1em 0; +} + +h4 { + display: block; + font-weight: bold; + margin: 1.33em 0; +} + +h5 { + display: block; + font-size: 0.83em; + font-weight: bold; + margin: 1.67em 0; +} + +h6 { + display: block; + font-size: 0.67em; + font-weight: bold; + margin: 2.33em 0; +} + .subsubsub { list-style: none; - margin: 15px 0 10px 0; + margin: 14px 0 8px 0; padding: 0; white-space: nowrap; font-size: 12px; @@ -55,31 +97,58 @@ textarea, input, select { border-collapse: collapse; width: 100%; clear: both; + margin: 0; } .widefat a { text-decoration: none; } +.widefat abbr { + white-space: nowrap; +} + .widefat td, .widefat th { border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #ccc; - font-size: 12px; - padding: 10px 10px 20px; + font-size: 11px; vertical-align: text-top; } +.widefat td { + padding: 7px 15px 9px 10px; + vertical-align: top; +} + .widefat th { - padding-bottom: 8px; - padding-top: 10px; + padding: 9px 15px 6px 10px; text-align: left; + line-height: 1.3em; +} + +.widefat th input { + margin: 0 0 0 8px; + padding: 0; } .widefat .check-column { + text-align: right; + width: 1.5em; + padding: 0; + +} + +.widefat tbody th.check-column { + padding: 8px 0 22px; +} +/* +th.check-column + th, th.check-column + td { + padding-left: 5px; +} +*/ +.widefat .num { text-align: center; - vertical-align: text-top; - width: 3%; } .wrap, .updated, .error { @@ -93,11 +162,15 @@ textarea, input, select { .updated, .error { border-width: 1px; border-style: solid; - padding: 0 15px; + padding: 0 0.6em; max-width: 950px; margin-bottom: 1em; } +.updated p, .error p { + margin: 0.6em 0; +} + .wrap .updated, .wrap .error { margin: auto 0 0; } @@ -119,8 +192,5 @@ textarea, input, select { margin: 5px 0 0 -4px; padding: 0; padding-bottom: 7px; + padding-right: 280px; } - -#timestampdiv { - display: none; -}
\ No newline at end of file diff --git a/wp-admin/css/ie-rtl.css b/wp-admin/css/ie-rtl.css new file mode 100644 index 0000000..54cadd0 --- /dev/null +++ b/wp-admin/css/ie-rtl.css @@ -0,0 +1,53 @@ +/* footer */ +body, td { + font-family: Tahoma,Verdana,sans-serif; +} + +.wrap { + text-align: right; +} + +.wrap h2 { + margin: 5px 0 0 4px; +} + +#footer { + padding-left:50px; +} +#footer p { + background:none; + height:auto; + padding: 5px 5px 0; +} + +#bh { + padding-left: 15px; + padding-right: 0px; +} +/* write post */ +#poststuff .togbox { + margin-right:-16px; +} +#poststuff h3 { + padding-right:20px; +} + +p#widget-search, p#post-search { + padding-left: 15px; +} + +.widefat th { + padding-bottom: 8px; +} + +/* template editor */ +#template textarea { + float:left; +} + +/* Editor */ + +.mceToolbar { + direction: ltr; + text-align: left; +}
\ No newline at end of file diff --git a/wp-admin/css/ie.css b/wp-admin/css/ie.css index dd7deaa..39ef254 100644 --- a/wp-admin/css/ie.css +++ b/wp-admin/css/ie.css @@ -31,7 +31,7 @@ position: relative; } -#wpwrap, #wpcontent, #post, #wrap, #postdivrich, #postdiv, #poststuff, #titlediv, #post-body, #editorcontainer, .tablenav, .widget-control-list { +#wpwrap, #wpcontent, #post, #wrap, #postdivrich, #postdiv, #poststuff, #titlediv, #post-body, #editorcontainer, .tablenav, .widget-control-list, li.widget-list-control-item, #dragHelper, li.widget-list-control-item h4, .widget-sortable, .widget-control-actions { display: block; zoom: 100%; } @@ -54,5 +54,88 @@ form#template div { #ed_toolbar input { overflow: visible; - padding: 1px 5px; + padding: 0 4px; +} + +#poststuff h2 { + font-size: 1.6em; +} + +* html #poststuff h2 { + margin-left: 0; +} + +#bh { + padding-right: 15px; +} + +/* without this dashboard widgets appear in one column for some screen widths */ +div#dashboard-widgets { + padding-right: 1px; +} + +#tagchecklist { + display: block; + zoom: 100%; +} + +#tagchecklist span, #tagchecklist span a { + display: inline-block; + display: block; +} + +#tagchecklist span a { + margin: 4px 0 0 -9px; +} + +#poststuff .togbox { + margin-left: -19px; +} + +.tablenav .button-secondary, .nav .button-secondary { + padding: 0 1px; + vertical-align: middle; +} + +.tablenav select { + font-size: 13px; + display: inline-block; + vertical-align: top; + margin-top: 2px; +} + +.tablenav-pages .page-numbers { + display: inline-block; +} + +.tablenav-pages { + display: block; + margin-top: -3px; + +} + +#post-search .button, #widget-search .button { + padding: 1px; +} + +.widefat tr, .widefat th { + margin-bottom: 0; + border-spacing: 0; +} + +.widefat th input { + margin: 0 0 0 5px; +} + +.widefat .check-column { + padding: 6px 0 2px; +} + +.widefat tbody th.check-column { + padding: 4px 0 22px; +} + +.tablenav a.button-secondary { + display: inline-block; + padding: 2px 5px; } diff --git a/wp-admin/css/install-rtl.css b/wp-admin/css/install-rtl.css index 6912736..806dbc5 100644 --- a/wp-admin/css/install-rtl.css +++ b/wp-admin/css/install-rtl.css @@ -1,15 +1,19 @@ -body { font: 13px Tahoma, Georgia, "Times New Roman", Times, serif; } - -ul, ol { padding: 5px 20px 5px 5px; } - -h1, h2, h3 { font-family: "Times New Roman", Times, serif; font-weight: 700 } - -.step, th { text-align: left } - -input { font-family: "Times New Roman", Times, serif; padding: 1px } - -#logo { background: url(../wp-content/plugins/WP-Jalali/wp-fa-logo.png) center right no-repeat; text-align: left; } - -#admin_email {direction: ltr; text-align: left; } - -#footer { font-style: normal; }
\ No newline at end of file +body { + font-size: 11px;; +} +ul, ol { + padding: 5px 22px 5px 5px; +} +.form-table th { + text-align: right; +} +input { + padding: 1px +} +#logo { + text-align: left; +} +#admin_email { + direction: ltr; + text-align: left; +}
\ No newline at end of file diff --git a/wp-admin/css/install.css b/wp-admin/css/install.css index 5eb85cd..5f4164c 100644 --- a/wp-admin/css/install.css +++ b/wp-admin/css/install.css @@ -1,40 +1,124 @@ -html { background: #eee; } +html { background: #f1f1f1; } body { background: #fff; - color: #000; - font-family: Georgia, "Times New Roman", Times, serif; - margin-left: 20%; - margin-right: 20%; - padding: .2em 2em; + color: #333; + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + margin: 2em auto 0 auto; + width: 700px; + padding: 1em 2em; + -webkit-border-radius: 12px; + font-size: 62.5%; } +a { color: #2583ad; text-decoration: none; } + +a:hover { color: #d54e21; } + + h1 { - color: #006; font-size: 18px; - font-weight: lighter; + margin-bottom: 0; } h2 { font-size: 16px; } -p, li, dt { - line-height: 140%; +p, li { padding-bottom: 2px; + font-size: 1.3em; + line-height: 1.8em; +} + +code { + font-size: 1.3em; } -ul, ol { padding: 5px 5px 5px 20px; } +ul, ol { padding: 5px 5px 5px 22px; } -#logo { margin-bottom: 2em; } +#logo { margin: 6px 0 14px 0px; border-bottom: none;} .step a, .step input { font-size: 2em; } td input { font-size: 1.5em; } -.step, th { text-align: right; } +.step, th { text-align: left; padding: 0; } + +.submit input, .button, .button-secondary { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 6px; + border: none; + margin-left: 0; + font-size: 13px !important; + -moz-border-radius: 2px; + -khtml-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + color: #246; + background: #e5e5e5; +} + +.button-secondary { + background: #cee1ef; +} + +.submit input:hover, .button:hover, .button-secondary:hover { + color: #d54e21; +} + +.form-table { + border-collapse: collapse; + margin-top: 1em; + width: 100%; +} + +.form-table td { + margin-bottom: 9px; + padding: 10px; + border-bottom: 8px solid #fff; +} + +.form-table th { + font-size: 12px; + text-align: left; + padding: 12px 10px 10px 10px; + border-bottom: 8px solid #fff; + width: 110px; + vertical-align: top; +} + +.form-table tr { + background: #eaf3fa; +} + +.form-table code { + line-height: 18px; + font-size: 18px; +} + +.form-table p { + margin: 4px 0 0 0; + font-size: 11px; +} + +h1 { + border-bottom: 1px solid #dadada; + clear: both; + color: #666666; + font: 24px Georgia, "Times New Roman", Times, serif; + margin: 5px 0 0 -4px; + padding: 0; + padding-bottom: 7px; +} + +#error-page { + margin-top: 50px; +} + +#error-page p { + font-size: 14px; + line-height: 1.6em; +} -#footer { - text-align: center; - border-top: 1px solid #ccc; - padding-top: 1em; - font-style: italic; +#error-page code { + font-size: 1em; }
\ No newline at end of file diff --git a/wp-admin/css/login-rtl.css b/wp-admin/css/login-rtl.css new file mode 100644 index 0000000..fc27263 --- /dev/null +++ b/wp-admin/css/login-rtl.css @@ -0,0 +1,32 @@ +body { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + direction: rtl; +} +form { + margin-left:0; + margin-right:8px; +} +form .forgetmenot { + float:right; +} +form .submit { + float:left; +} +#login_error, .message { + margin:0 8px 16px 0; +} +#nav { + margin: 0 8px 0 0; +} +#user_pass, #user_login, #user_email { + margin-right:0; + margin-left: 6px; + direction:ltr; +} +h1 a { + text-decoration:none; +} +#backtoblog a { + left: auto; + right: 15px; +}
\ No newline at end of file diff --git a/wp-admin/css/media-rtl.css b/wp-admin/css/media-rtl.css new file mode 100644 index 0000000..f0c00df --- /dev/null +++ b/wp-admin/css/media-rtl.css @@ -0,0 +1,21 @@ +ul#sidemenu { + left: auto; + right: 0; +} +.align .field label { + display: block; + float: right; + padding: 0 25px 0 0; + margin: 5px 3px 5px 5px; +} +.align .field input { + display: block; + float: right; + margin: 5px 15px 5px 0; +} +.image-align-none-label, +.image-align-left-label, +.image-align-center-label, +.image-align-right-label { + background-position: center right; +}
\ No newline at end of file diff --git a/wp-admin/css/media.css b/wp-admin/css/media.css index a5b354e..0cb2694 100644 --- a/wp-admin/css/media.css +++ b/wp-admin/css/media.css @@ -8,7 +8,7 @@ div#media-upload-header { height: 2.5em; } -ul#sidemenu { +body#media-upload ul#sidemenu { font-weight: normal; margin: 0 5px; position: absolute; @@ -235,4 +235,8 @@ abbr.required { } #media-upload tr.align td.field { text-align: center; +} +#media-upload tr.image-size { + margin-bottom: 1em; + height: 3em; }
\ No newline at end of file diff --git a/wp-admin/css/mu.css b/wp-admin/css/mu.css new file mode 100644 index 0000000..22ae74e --- /dev/null +++ b/wp-admin/css/mu.css @@ -0,0 +1,35 @@ +/* Blog Switcher */ + +#all-my-blogs-tab a.current { + position: relative; + padding-bottom: 10px; +} + +#all-my-blogs { + position: absolute; + top: 30px; + left: 0; + right: 0; + _width: 100%; /* IE6 Hack */ + margin: 4px 7px; + padding: 6px 10px; + font-size: 12px; +} + +#all-my-blogs * { + margin: 0; +} + +form#all-my-blogs p, form#all-my-blogs p * { + vertical-align: middle; +} + +#all-my-blogs a { + font-size: 10px; + text-decoration: underline; + margin: 0 14px; +} + +#all-my-blogs a:hover, #all-my-blogs a:active { + text-decoration: none; +} diff --git a/wp-admin/css/theme-editor-rtl.css b/wp-admin/css/theme-editor-rtl.css new file mode 100644 index 0000000..407886b --- /dev/null +++ b/wp-admin/css/theme-editor-rtl.css @@ -0,0 +1,11 @@ +#templateside { + float:left; +} +#themeselector { + padding-right:0; + padding-left:5px; +} +div.tablenav { + margin-left:210px; + margin-right:0; +}
\ No newline at end of file diff --git a/wp-admin/css/theme-editor.css b/wp-admin/css/theme-editor.css index eaaa946..2c59e97 100644 --- a/wp-admin/css/theme-editor.css +++ b/wp-admin/css/theme-editor.css @@ -18,6 +18,14 @@ margin: 0; } +h3#bordertitle { + margin-bottom: 10px; +} + +#templateside h4 { + margin-bottom: 0px; +} + #templateside ol, #templateside ul { list-style: none; margin: .5em; @@ -35,10 +43,24 @@ bottom: 25px; } +#themeselector select { + margin: 0; + padding: 0; +} + .nonessential { font-size: small; } .highlight { padding: 1px; -}
\ No newline at end of file +} + +div.bordertitle h2 { + border: none; + padding-bottom: 0px; +} + +div.tablenav { + margin-right: 210px; +} diff --git a/wp-admin/css/upload-rtl.css b/wp-admin/css/upload-rtl.css new file mode 100644 index 0000000..dc13a4b --- /dev/null +++ b/wp-admin/css/upload-rtl.css @@ -0,0 +1,12 @@ +html { + direction: ltr; + } +#uploadoptions, table { + direction: rtl; + } +td { + padding: 1px 6px 0; + } +.submit { + text-align: left; + }
\ No newline at end of file diff --git a/wp-admin/css/widgets-rtl.css b/wp-admin/css/widgets-rtl.css index d76cc9f..49359f5 100644 --- a/wp-admin/css/widgets-rtl.css +++ b/wp-admin/css/widgets-rtl.css @@ -1,38 +1,50 @@ -.dropzone, -#palettediv, -.handle, -.controlform { - direction: rtl; - text-align: justify; - } -.dropzone { - float: right; - margin-left: 10px; - margin-right: auto; - width: 240px; - } -* html .dropzone ul { - margin-right: 0; - } -* .handle, #lastmodule span { - border-left: 1px solid #e8e8e8; - border-right: 1px solid #f2f2f2; - } -* .popper { - right: auto; - left: 3px; - } -#palettediv .module, #lastmodule { - margin-right: auto; - margin-left: 10px; - float: right; - } -#palettediv ul { - padding: 0 10px 0 0; - margin-right: 0; - width: 100%; - } -.placemat { - margin-right: 0; - float: right; - }
\ No newline at end of file +div.widget-liquid-left-holder { + clear:right; + float:right; + margin-right:0; + margin-left:-310px; +} +div.widget-liquid-left { + margin-right:0; + margin-left:310px; +} +div.widget-liquid-right { + clear:left; + float:left; +} +p#widget-search { + left:0; + right:auto +} +ul#widget-list li.widget-list-item h4.widget-title { + float:right; + text-align:right; +} +ul#widget-list li.widget-list-item div.widget-description { + margin:0 200px 0 0; + padding:0 4em 0 0; +} +.widget-control-save, .widget-control-remove { + float:right; + margin-right:0; + margin-left:8px; +} +h4.widget-title a { + right:auto; + left:1em; +} +li.widget-list-control-item h4.widget-title a, #dragHelper li.widget-list-control-item h4.widget-title a, #draghelper li.widget-list-control-item h4.widget-title a:visited { + right:auto; + left:2em; +} + +li.widget-list-control-item div.widget-control { + padding:0 0 0 10px; +} +ul.widget-control-list div.widget-control-actions { + margin-right:0; + margin-left:-10px; +} +ul.widget-control-list .widget-title { + text-align:right; +}
\ No newline at end of file diff --git a/wp-admin/css/widgets.css b/wp-admin/css/widgets.css index f46c4ce..ea70396 100644 --- a/wp-admin/css/widgets.css +++ b/wp-admin/css/widgets.css @@ -1,236 +1,190 @@ -body { - height: 100%; -} - -#sbadmin #zones { - -moz-user-select: none; - -khtml-user-select: none; - user-select: none; -} - -#sbreset { +/* 2 column liquid layout */ +div.widget-liquid-left-holder { float: left; - margin: 1px 0; -} - -.dropzone { - border: 1px solid #bbb; - float: left; - margin-right: 10px; - padding: 5px; - background-color: #f0f8ff; -} - -.dropzone h3 { - text-align: center; - color: #333; + clear: left; + width: 100%; + margin-right: -310px; } -.dropzone input { - display: none; +div.widget-liquid-left { + margin-right: 320px; } -.dropzone ul { - float: left; - list-style-type: none; - width: 240px; - margin: 0; - min-height: 200px; - padding: 0; - display: block; +div.widget-liquid-right { + float: right; + clear: right; + width: 300px; + position: relative; } -* .module { - width: 238px; - padding: 0; - margin: 5px 0; - cursor: move; - display: block; - border: 1px solid #ccc; - background-color: #fbfbfb; +/* pasitioning etc. */ +form#widgets-filter { position: relative; - text-align: left; - line-height: 25px; } -* .handle { - display: block; - width: 216px; - padding: 0 10px; - position: relative; - border-top: 1px solid #f2f2f2; - border-right: 1px solid #e8e8e8; - border-bottom: 1px solid #e8e8e8; - border-left: 1px solid #f2f2f2; +div#available-widgets-filter { + border-bottom-width: 1px; + border-bottom-style: solid; } -* .popper { - margin: 0; - display: inline; +p#widget-search { position: absolute; - top: 3px; - right: 3px; - overflow: hidden; - text-align: center; - height: 16px; - font-size: 18px; - line-height: 14px; - cursor: pointer; - padding: 0 3px 1px; - border-top: 4px solid #6da6d1; - background: url( ../images/fade-butt.png ) -5px 0px; -} - -* html .popper { - padding: 1px 6px 0; - font-size: 16px; -} - -#sbadmin p.submit { - padding-right: 10px; - clear: left; + right: 0; + top: 0; + margin: 0; } -.placemat { - cursor: default; +ul#widget-list { + list-style: none; margin: 0; padding: 0; - position: relative; } -.placemat h4 { - text-align: center; -} - -.placemat span { - background-color: #ffe; - border: 1px solid #ccc; - padding: 0 10px 10px; - position: absolute; - text-align: justify; +ul#widget-list li.widget-list-item { + padding: .7em 0.9em; + margin: 0; + border-bottom-width: 1px; + border-bottom-style: solid; + background-color: transparent; + line-height: 1; } -#palettediv { - border: 1px solid #bbb; - background-color: #f0f8ff; - height:auto; - margin-top: 10px; - padding-bottom: 10px; +ul#widget-list li.widget-list-item h4.widget-title { + position: relative; + margin: 0; + padding: .5em 1em; + width: 200px; + float: left; + font-size: 13px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px;; } -#palettediv:after, #zones:after, .dropzone:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; +#dragHelper h4.widget-title { + padding: .5em 1em; + margin: 0; } -#palettediv, #zones, .dropzone { +ul#widget-list li.widget-list-item div.widget-description { display: block; - min-height: 1px; + margin: 0 0 0 200px; + padding: 0 0 0 4em; + font-size: 11px; } -* html #palettediv, * html #zones, * html .dropzone { - height: 1%; -} -#palettediv h3 { - text-align: center; - color: #333; - min-height: 1px; +ul#widget-list li.widget-list-item ul.widget-control-info { + display: none; } -#palettediv ul { - padding: 0 0 0 10px; +div#sidebar-info { + padding: 0 1em; + margin-bottom: 1em; + font-size: 11px; } -#palettediv .module { - margin-right: 10px; - float: left; - width: 120px; +ul.widget-control-list { + list-style: none; + margin: 0; + padding: 0 1em; } -#palettediv .handle { - height: 40px; - font-size: 90%; - width: 110px; - padding: 0 5px; +div#current-widgets p.submit { + padding: 1em; } -#palettediv .popper { - visibility: hidden; +li.widget-list-control-item { + margin: 0 0 1em; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } -* html #palettediv ul { +li.widget-list-control-item h4, #dragHelper li.widget-list-control-item h4, li.widget-sortable h4 { margin: 0; - padding: 0 0 0 10px; + padding: 0.4em 2.5em 0.4em 0.8em; + cursor: move; + font-size: 13px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +.widget-control-save, .widget-control-remove { + padding: 3px 5px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + margin-right: 8px; + float: left; + text-decoration: none; } -#controls { - height: 0px; +h4.widget-title a { + position: absolute; + right: 1em; + text-decoration: underline; + border-bottom: none; } -.control { - position: absolute; - display: block; - background: #f9fcfe; - padding: 0; +li.widget-list-control-item h4.widget-title a, +#dragHelper li.widget-list-control-item h4.widget-title a, +#draghelper li.widget-list-control-item h4.widget-title a:visited { + right: 2em; } -.controlhandle { - cursor: move; - background-color: #6da6d1; - border-bottom: 2px solid #448abd; - color: #333; - display: block; - margin: 0 0 5px; - padding: 4px; - font-size: 120%; +li.widget-list-control-item h4.widget-title a:hover { + + text-decoration: none; + border-bottom: none; } -.controlcloser { - cursor: pointer; - font-size: 120%; - display: block; - position: absolute; - top: 2px; - right: 8px; - padding: 0 3px; - font-weight: bold; +li.widget-list-control-item div.widget-control { + display: none; + margin: 1em; + padding: 0 10px 0 7px; /* Correction for padding, margin, border of inputs */ + font-size: 11px; } -.controlform { - margin: 20px 30px; +li.widget-list-control-item div.widget-control p { + margin: 0 0 1em; + padding: 0; } -.controlform p { - text-align: center; +ul.widget-control-list div.widget-control-actions { + margin-right: -10px; /* Correction for padding, margin, border of inputs */ + margin-left: -6px; + border-top-width: 1px; + border-top-style: solid; + padding: 0.5em 0 0.8em; } -.control .checkbox { - border: none; - background: transparent; +ul.widget-control-list .widget-title { + } -.hidden { - display: none; +.widget-control-edit { + font-size: 10px; + font-weight: normal; } -#shadow { - background: black; - display: none; - position: absolute; - top: 0px; - left: 0px; - width: 100%; +div#current-widgets { + padding-top: 1em; + border-width: 1px; + border-style: solid none none; } -#dragHelper { - position: absolute; +#widget-controls .widefat { + width: 92%; + padding: 3px; } -#dragHelper li.module { +#widget-controls select.widefat { + width: auto; display: block; - float: left; } diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index 8d60565..c5e5d20 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -169,7 +169,7 @@ Event.observe( window, 'load', hide_text ); <input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" /> <input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" /> <?php wp_nonce_field('custom-header') ?> -<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes »'); ?>" /></form> +<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?>" /></form> <?php } ?> <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div> @@ -183,7 +183,7 @@ Event.observe( window, 'load', hide_text ); <input type="hidden" name="action" value="save" /> <?php wp_nonce_field('custom-header') ?> <p class="submit"> -<input type="submit" value="<?php _e('Upload »'); ?>" /> +<input type="submit" value="<?php _e('Upload'); ?>" /> </p> </form> @@ -211,6 +211,7 @@ Event.observe( window, 'load', hide_text ); die( $file['error'] ); $url = $file['url']; + $type = $file['type']; $file = $file['file']; $filename = basename($file); @@ -218,19 +219,20 @@ Event.observe( window, 'load', hide_text ); $object = array( 'post_title' => $filename, 'post_content' => $url, - 'post_mime_type' => 'import', + 'post_mime_type' => $type, 'guid' => $url); // Save the data $id = wp_insert_attachment($object, $file); - $upload = array('file' => $file, 'id' => $id); - list($width, $height, $type, $attr) = getimagesize( $file ); if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { + // Add the meta-data + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + set_theme_mod('header_image', clean_url($url)); - $header = apply_filters('wp_create_file_in_uploads', $file, $id); // For replication + do_action('wp_create_file_in_uploads', $file, $id); // For replication return $this->finished(); } elseif ( $width > HEADER_IMAGE_WIDTH ) { $oitar = $width / HEADER_IMAGE_WIDTH; @@ -264,7 +266,7 @@ Event.observe( window, 'load', hide_text ); <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $id; ?>" /> <input type="hidden" name="oitar" id="oitar" value="<?php echo $oitar; ?>" /> <?php wp_nonce_field('custom-header') ?> -<input type="submit" value="<?php _e('Crop Header »'); ?>" /> +<input type="submit" value="<?php _e('Crop Header'); ?>" /> </p> </form> @@ -281,22 +283,34 @@ Event.observe( window, 'load', hide_text ); $_POST['height'] = $_POST['height'] * $_POST['oitar']; } - $header = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); - $header = apply_filters('wp_create_file_in_uploads', $header); // For replication + $original = get_attached_file( $_POST['attachment_id'] ); - $parent = get_post($_POST['attachment_id']); + $cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $_POST['attachment_id']); // For replication + $parent = get_post($_POST['attachment_id']); $parent_url = $parent->guid; + $url = str_replace(basename($parent_url), basename($cropped), $parent_url); + + // Construct the object array + $object = array( + 'ID' => $_POST['attachment_id'], + 'post_title' => basename($cropped), + 'post_content' => $url, + 'post_mime_type' => 'image/jpeg', + 'guid' => $url + ); - $url = str_replace(basename($parent_url), basename($header), $parent_url); + // Update the attachment + wp_insert_attachment($object, $cropped); + wp_update_attachment_metadata( $_POST['attachment_id'], wp_generate_attachment_metadata( $_POST['attachment_id'], $cropped ) ); set_theme_mod('header_image', $url); // cleanup - $file = get_attached_file( $_POST['attachment_id'] ); - $medium = str_replace(basename($file), 'midsize-'.basename($file), $file); + $medium = str_replace(basename($original), 'midsize-'.basename($original), $original); @unlink( apply_filters( 'wp_delete_file', $medium ) ); - wp_delete_attachment( $_POST['attachment_id'] ); + @unlink( apply_filters( 'wp_delete_file', $original ) ); return $this->finished(); } diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php index 8eb9066..407436b 100644 --- a/wp-admin/edit-attachment-rows.php +++ b/wp-admin/edit-attachment-rows.php @@ -4,22 +4,26 @@ <tr> <?php $posts_columns = wp_manage_media_columns(); ?> -<?php foreach($posts_columns as $column_display_name) { ?> - <th scope="col"><?php echo $column_display_name; ?></th> +<?php foreach($posts_columns as $post_column_key => $column_display_name) { + if ( 'cb' === $post_column_key ) + $class = ' class="check-column"'; + elseif ( 'comments' === $post_column_key ) + $class = ' class="num"'; + else + $class = ''; +?> + <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th> <?php } ?> </tr> </thead> <tbody id="the-list" class="list:post"> <?php -$i_post = 0; if ( have_posts() ) { $bgcolor = ''; add_filter('the_title','wp_specialchars'); -while (have_posts()) : the_post(); $i_post++; -if ( 16 == $i_post ) - echo "\t</tbody>\n\t<tbody id='the-extra-list' class='list:post' style='display: none'>\n"; // Hack! -$class = ( $i_post > 15 || 'alternate' == $class) ? '' : 'alternate'; +while (have_posts()) : the_post(); +$class = 'alternate' == $class ? '' : 'alternate'; global $current_user; $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); ?> @@ -33,20 +37,20 @@ foreach($posts_columns as $column_name=>$column_display_name) { case 'cb': ?> - <th scope="row" style="text-align: center"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th> + <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th> <?php break; case 'icon': ?> - <td class="media-icon"><?php echo wp_get_attachment_link($post->ID, array(60, 40), false, true); ?></td> + <td class="media-icon"><?php echo wp_get_attachment_link($post->ID, array(80, 60), false, true); ?></td> <?php // TODO break; case 'media': ?> - <td><strong><a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>"><?php the_title(); ?></a></strong><br /> + <td><strong><a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), get_the_title())); ?>"><?php the_title(); ?></a></strong><br /> <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?> <?php do_action('manage_media_media_column', $post->ID); ?> </td> @@ -81,21 +85,27 @@ foreach($posts_columns as $column_name=>$column_display_name) { break; case 'parent': - if ( $post_parent = get_post($post->post_parent) ) { - $title = get_the_title($post->post_parent); - if ( empty($title) ) - $title = __('(no title)'); + $title = __('(no title)'); // override below + if ( $post->post_parent > 0 ) { + if ( get_post($post->post_parent) ) { + $parent_title = get_the_title($post->post_parent); + if ( !empty($parent_title) ) + $title = $parent_title; + } + ?> + <td><strong><a href="post.php?action=edit&post=<?php echo $post->post_parent; ?>"><?php echo $title ?></a></strong></td> + <?php } else { - $title = ''; + ?> + <td> </td> + <?php } - ?> - <td><strong><a href="post.php?action=edit&post=<?php echo $post->post_parent; ?>"><?php echo $title ?></a></strong></td> - <?php + break; case 'comments': ?> - <td style="text-align: center"> + <td class="num"><div class="post-com-count-wrapper"> <?php $left = get_pending_comments_num( $post->ID ); $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); @@ -105,7 +115,7 @@ foreach($posts_columns as $column_name=>$column_display_name) { if ( $left ) echo '</strong>'; ?> - </td> + </div></td> <?php break; diff --git a/wp-admin/edit-category-form.php b/wp-admin/edit-category-form.php index 4696129..545305d 100644 --- a/wp-admin/edit-category-form.php +++ b/wp-admin/edit-category-form.php @@ -1,15 +1,15 @@ <?php if ( ! empty($cat_ID) ) { $heading = __('Edit Category'); - $submit_text = __('Edit Category »'); - $form = '<form name="editcat" id="editcat" method="post" action="categories.php">'; + $submit_text = __('Edit Category'); + $form = '<form name="editcat" id="editcat" method="post" action="categories.php" class="validate">'; $action = 'editedcat'; $nonce_action = 'update-category_' . $cat_ID; do_action('edit_category_form_pre', $category); } else { $heading = __('Add Category'); - $submit_text = __('Add Category »'); - $form = '<form name="addcat" id="addcat" method="post" action="categories.php">'; + $submit_text = __('Add Category'); + $form = '<form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">'; $action = 'addcat'; $nonce_action = 'add-category'; do_action('add_category_form_pre', $category); @@ -23,23 +23,28 @@ if ( ! empty($cat_ID) ) { <input type="hidden" name="action" value="<?php echo $action ?>" /> <input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" /> <?php wp_nonce_field($nonce_action); ?> - <table class="editform" width="100%" cellspacing="2" cellpadding="5"> - <tr> - <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th> - <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->name); ?>" size="40" /></td> + <table class="form-table"> + <tr class="form-field form-required"> + <th scope="row" valign="top"><label for="cat_name"><?php _e('Category Name') ?></label></th> + <td><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->name); ?>" size="40" /><br /> + <?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></td> </tr> - <tr> + <tr class="form-field"> <th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th> + <tr class="form-field"> + <th scope="row" valign="top"><label for="category_parent"><?php _e('Category Parent') ?></label></th> <td> - <?php wp_dropdown_categories('hide_empty=0&name=category_parent&orderby=name&selected=' . $category->parent . '&hierarchical=1&show_option_none=' . __('None')); ?> + <?php wp_dropdown_categories('hide_empty=0&name=category_parent&orderby=name&selected=' . $category->parent . '&hierarchical=1&show_option_none=' . __('None')); ?><br /> + <?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?> </td> </tr> - <tr> - <th scope="row" valign="top"><label for="category_description"><?php _e('Description: (optional)') ?></label></th> - <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->description); ?></textarea></td> + <tr class="form-field"> + <th scope="row" valign="top"><label for="category_description"><?php _e('Description') ?></label></th> + <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->description); ?></textarea><br /> + <?php _e('The description is not prominent by default, however some themes may show it.'); ?></td> </tr> </table> -<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p> +<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p> <?php do_action('edit_category_form', $category); ?> </form> </div> diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index ab1bdbc..bc62681 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -4,76 +4,133 @@ require_once('admin.php'); $title = __('Edit Comments'); $parent_file = 'edit-comments.php'; wp_enqueue_script( 'admin-comments' ); +wp_enqueue_script('admin-forms'); + +if ( !empty( $_REQUEST['delete_comments'] ) ) { + check_admin_referer('bulk-comments'); + + $comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0; + foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each + $comment = (int) $comment; + $post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); + // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); + if ( !current_user_can('edit_post', $post_id) ) + continue; + if ( !empty( $_REQUEST['spamit'] ) ) { + wp_set_comment_status($comment, 'spam'); + $comments_spammed++; + } elseif ( !empty( $_REQUEST['deleteit'] ) ) { + wp_set_comment_status($comment, 'delete'); + $comments_deleted++; + } elseif ( !empty( $_REQUEST['approveit'] ) ) { + wp_set_comment_status($comment, 'approve'); + $comments_approved++; + } elseif ( !empty( $_REQUEST['unapproveit'] ) ) { + wp_set_comment_status($comment, 'hold'); + $comments_unapproved++; + } + endforeach; + $redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved; + if ( !empty($_REQUEST['mode']) ) + $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to); + if ( !empty($_REQUEST['comment_status']) ) + $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to); + if ( !empty($_REQUEST['s']) ) + $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to); + wp_redirect( $redirect_to ); +} elseif ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; +} require_once('admin-header.php'); -if (empty($_GET['mode'])) $mode = 'view'; -else $mode = attribute_escape($_GET['mode']); + +if ( empty($_GET['mode']) ) + $mode = 'detail'; +else + $mode = attribute_escape($_GET['mode']); + +if ( isset($_GET['comment_status']) ) + $comment_status = attribute_escape($_GET['comment_status']); +else + $comment_status = ''; + +if ( isset($_GET['s']) ) + $search_dirty = $_GET['s']; +else + $search_dirty = ''; +$search = attribute_escape( $search_dirty ); ?> +<?php +if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) { + $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; + $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; + $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0; + + if ( $approved > 0 || $deleted > 0 || $spam > 0 ) { + echo '<div id="moderated" class="updated fade"><p>'; -<script type="text/javascript"> -<!-- -function checkAll(form) -{ - for (i = 0, n = form.elements.length; i < n; i++) { - if(form.elements[i].type == "checkbox") { - if(form.elements[i].checked == true) - form.elements[i].checked = false; - else - form.elements[i].checked = true; + if ( $approved > 0 ) { + printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved ); + echo '<br />'; } - } -} -function getNumChecked(form) -{ - var num = 0; - for (i = 0, n = form.elements.length; i < n; i++) { - if(form.elements[i].type == "checkbox") { - if(form.elements[i].checked == true) - num++; + if ( $deleted > 0 ) { + printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); + echo '<br />'; } + + if ( $spam > 0 ) { + printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); + echo '<br />'; + } + + echo '</p></div>'; } - return num; } -//--> -</script> +?> <div class="wrap"> -<h2><?php _e('Comments'); ?></h2> -<form name="searchform" action="" method="get" id="editcomments"> - <fieldset> - <legend><?php _e('Show Comments That Contain...') ?></legend> - <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" /> - <input type="submit" name="submit" value="<?php _e('Search') ?>" /> - <input type="hidden" name="mode" value="<?php echo $mode; ?>" /> - <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?> - </fieldset> -</form> -<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p> +<form id="posts-filter" action="" method="get"> +<h2><?php _e('Manage Comments'); ?></h2> + +<ul class="subsubsub"> <?php -if ( !empty( $_POST['delete_comments'] ) ) : - check_admin_referer('bulk-comments'); +$status_links = array(); +$num_comments = wp_count_comments(); +$stati = array('moderated' => sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', $num_comments->moderated), "<span class='comment-count'>$num_comments->moderated</span>"), 'approved' => _c('Approved|plural')); +$class = ( '' === $comment_status ) ? ' class="current"' : ''; +$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>"; +foreach ( $stati as $status => $label ) { + $class = ''; + + if ( $status == $comment_status ) + $class = ' class="current"'; + + $status_links[] = "<li><a href=\"edit-comments.php?comment_status=$status\"$class>" . $label . '</a>'; +} - $i = 0; - foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each - $comment = (int) $comment; - $post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); - // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); - if ( current_user_can('edit_post', $post_id) ) { - if ( !empty( $_POST['spam_button'] ) ) - wp_set_comment_status($comment, 'spam'); - else - wp_set_comment_status($comment, 'delete'); - ++$i; - } - endforeach; - echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; - if ( !empty( $_POST['spam_button'] ) ) { - printf(__ngettext('%s comment marked as spam', '%s comments marked as spam.', $i), $i); - } else { - printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i); - } - echo '</p></div>'; -endif; +$status_links = apply_filters( 'comment_status_links', $status_links ); + +echo implode(' | </li>', $status_links) . '</li>'; +unset($status_links); +?> +</ul> + +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php echo $search; ?>" /> + <input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" /> +</p> + +<input type="hidden" name="mode" value="<?php echo $mode; ?>" /> +<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" /> +</form> + +<ul class="view-switch"> + <li <?php if ( 'detail' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'detail', $_SERVER['REQUEST_URI'])) ?>"><?php _e('Detail View') ?></a></li> + <li <?php if ( 'list' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><?php _e('List View') ?></a></li> +</ul> + +<?php if ( isset( $_GET['apage'] ) ) $page = abs( (int) $_GET['apage'] ); @@ -82,7 +139,7 @@ else $start = $offset = ( $page - 1 ) * 20; -list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra +list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, 25 ); // Grab a few extra $comments = array_slice($_comments, 0, 20); $extra_comments = array_slice($_comments, 20); @@ -94,109 +151,94 @@ $page_links = paginate_links( array( 'current' => $page )); -if ( $page_links ) - echo "<p class='pagenav'>$page_links</p>"; - -if ('view' == $mode) { - if ($comments) { - $offset = $offset + 1; - $start = " start='$offset'"; - - echo "<ol id='the-comment-list' class='commentlist' $start>\n"; - $i = 0; - foreach ( $comments as $comment ) { - get_comment( $comment ); // Cache it - _wp_comment_list_item( $comment->comment_ID, ++$i ); - } - echo "</ol>\n\n"; - -if ( $extra_comments ) : ?> -<div id="extra-comments" style="display:none"> -<ul id="the-extra-comment-list" class="commentlist"> -<?php - foreach ( $extra_comments as $comment ) { - get_comment( $comment ); // Cache it - _wp_comment_list_item( $comment->comment_ID, ++$i ); - } ?> -</ul> -</div> -<?php endif; // $extra_comments ?> -<div id="ajax-response"></div> +<form id="comments-form" action="" method="post"> + +<div class="tablenav"> <?php - } else { //no comments to show +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; +?> - ?> - <p> - <strong><?php _e('No comments found.') ?></strong></p> +<div class="alignleft"> +<?php if ( 'approved' != $comment_status ): ?> +<input type="submit" value="<?php _e('Approve'); ?>" name="approveit" class="button-secondary" /> +<?php endif; ?> +<input type="submit" value="<?php _e('Mark as Spam'); ?>" name="spamit" class="button-secondary" /> +<?php if ( 'moderated' != $comment_status ): ?> +<input type="submit" value="<?php _e('Unapprove'); ?>" name="unapproveit" class="button-secondary" /> +<?php endif; ?> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php do_action('manage_comments_nav', $comment_status); ?> +<?php wp_nonce_field('bulk-comments'); ?> +</div> - <?php - } // end if ($comments) -} elseif ('edit' == $mode) { +<br class="clear" /> - if ($comments) { - echo '<form name="deletecomments" id="deletecomments" action="" method="post"> '; - wp_nonce_field('bulk-comments'); - echo '<table class="widefat"> +</div> + +<br class="clear" /> +<?php +if ($comments) { +?> +<table class="widefat"> <thead> <tr> - <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th> - <th scope="col">' . __('Name') . '</th> - <th scope="col">' . __('E-mail') . '</th> - <th scope="col">' . __('IP') . '</th> - <th scope="col">' . __('Comment Excerpt') . '</th> - <th scope="col" colspan="3" style="text-align: center">' . __('Actions') . '</th> + <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('comments-form'));" /></th> + <th scope="col"><?php _e('Comment') ?></th> + <th scope="col"><?php _e('Date') ?></th> + <th scope="col" class="action-links"><?php _e('Actions') ?></th> </tr> -</thead>'; - foreach ($comments as $comment) { - $post = get_post($comment->comment_post_ID); - $authordata = get_userdata($post->post_author); - $comment_status = wp_get_comment_status($comment->comment_ID); - $class = ('alternate' == $class) ? '' : 'alternate'; - $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; +</thead> +<tbody id="the-comment-list" class="list:comment"> +<?php + foreach ($comments as $comment) + _wp_comment_row( $comment->comment_ID, $mode, $comment_status ); ?> - <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> - <td style="text-align: center"><?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> - <td><?php comment_author_link() ?></td> - <td><?php comment_author_email_link() ?></td> - <td><a href="edit-comments.php?s=<?php comment_author_IP() ?>&mode=edit"><?php comment_author_IP() ?></a></td> - <td><?php comment_excerpt(); ?></td> - <td> - <?php if ('unapproved' == $comment_status) { - _e('Unapproved'); - } else { ?> - <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a> - <?php } ?> - </td> - <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { - echo "<a href='comment.php?action=editcomment&c=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> - <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { - echo "<a href=\"comment.php?action=deletecomment&p=".$comment->comment_post_ID."&c=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'. \n 'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> "; - } ?></td> - </tr> - <?php - } // end foreach - ?></table> -<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments »') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to delete")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to delete %s comments permanently \n 'Cancel' to stop, 'OK' to delete.")), "' + numchecked + '"); ?>')" /> - <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam »') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to mark as spam")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to mark %s comments as spam \n 'Cancel' to stop, 'OK' to mark as spam.")), "' + numchecked + '"); ?>')" /></p> - </form> +</tbody> +<tbody id="the-extra-comment-list" class="list:comment" style="display: none;"> +<?php + foreach ($extra_comments as $comment) + _wp_comment_row( $comment->comment_ID, $mode, $comment_status ); +?> +</tbody> +</table> + +</form> + +<form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;"> + <input type="hidden" name="s" value="<?php echo $search; ?>" /> + <input type="hidden" name="mode" value="<?php echo $mode; ?>" /> + <input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" /> + <input type="hidden" name="page" value="<?php echo isset($_REQUEST['page']) ? absint( $_REQUEST['page'] ) : 1; ?>" /> + <?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?> +</form> + <div id="ajax-response"></div> <?php - } else { +} elseif ( 'moderated' == $_GET['comment_status'] ) { ?> <p> -<strong><?php _e('No results found.') ?></strong> +<?php _e('No comments awaiting moderation… yet.') ?> +</p> +<?php +} else { +?> +<p> +<?php _e('No results found.') ?> </p> <?php - } // end if ($comments) } - +?> +<div class="tablenav"> +<?php if ( $page_links ) - echo "<p class='pagenav'>$page_links</p>"; - + echo "<div class='tablenav-pages'>$page_links</div>"; ?> +<br class="clear" /> +</div> </div> diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index ab3adff..c71aa71 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -1,12 +1,14 @@ <?php +$action = isset($action)? $action : ''; if ( isset($_GET['message']) ) - $_GET['message'] = (int) $_GET['message']; -$messages[1] = __('Post updated'); -$messages[2] = __('Custom field updated'); + $_GET['message'] = absint( $_GET['message'] ); +$messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); +$messages[2] = __('Custom field updated.'); $messages[3] = __('Custom field deleted.'); +$messages[4] = __('Post updated.'); ?> <?php if (isset($_GET['message'])) : ?> -<div id="message" class="updated fade"><p><?php echo wp_specialchars($messages[$_GET['message']]); ?></p></div> +<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> <?php endif; ?> <form name="post" action="post.php" method="post" id="post"> @@ -15,9 +17,10 @@ $messages[3] = __('Custom field deleted.'); <?php endif; ?> <div class="wrap"> +<h2><?php _e('Write Post') ?></h2> <?php -if (0 == $post_ID) { +if (!isset($post_ID) || 0 == $post_ID) { $form_action = 'post'; $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />"; @@ -44,196 +47,236 @@ if ('' != $post->pinged) { $pings .= '</ul>'; } -$saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />'; - -if (empty($post->post_status)) $post->post_status = 'draft'; +$saveasdraft = '<input name="save" type="submit" id="save" class="button" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />'; ?> -<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> +<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> <input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" /> <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" /> <input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" /> -<input type="hidden" id="post_type" name="post_type" value="post" /> +<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" /> +<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" /> +<input name="referredby" type="hidden" id="referredby" value="<?php +if ( !empty($_REQUEST['popupurl']) ) + echo clean_url(stripslashes($_REQUEST['popupurl'])); +else if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false ) + echo 'redo'; +else + echo clean_url(stripslashes(wp_get_referer())); +?>" /> +<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?> <?php echo $form_extra ?> -<?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?> -<script type="text/javascript"> -function focusit() { - // focus on first input field - document.post.title.focus(); -} -addLoadEvent(focusit); -</script> -<?php endif; ?> -<div id="poststuff"> -<div id="moremeta"> -<div id="grabit" class="dbx-group"> +<div id="poststuff"> -<fieldset id="categorydiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Categories') ?></h3> -<div class="dbx-content"> -<p id="jaxcat"></p> -<ul id="categorychecklist"><?php dropdown_categories(); ?></ul></div> -</fieldset> +<div class="submitbox" id="submitpost"> -<fieldset id="commentstatusdiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Discussion') ?></h3> -<div class="dbx-content"> -<input name="advanced_view" type="hidden" value="1" /> -<label for="comment_status" class="selectit"> -<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> -<?php _e('Allow Comments') ?></label> -<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label> +<div id="previewview"> +<?php if ( 'publish' == $post->post_status ) { ?> +<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View this Post'); ?></a> +<?php } elseif ( 'edit' == $action ) { ?> +<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview this Post'); ?></a> +<?php } ?> </div> -</fieldset> -<fieldset id="passworddiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Post Password') ?></h3> -<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div> -</fieldset> +<div class="inside"> -<fieldset id="slugdiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Post Slug') ?></h3> -<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div> -</fieldset> - -<fieldset id="poststatusdiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Post Status') ?></h3> -<div class="dbx-content"> -<?php if ( current_user_can('publish_posts') ) : ?> - <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label> +<p><strong><?php _e('Publish Status') ?></strong></p> +<p> +<select name='post_status' tabindex='4'> +<?php if ( current_user_can('publish_posts') ) : // Contributors only get "Unpublished" and "Pending Review" ?> +<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option> +<?php if ( 'future' == $post->post_status ) : ?> +<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> <?php endif; ?> - <label for="post_status_pending" class="selectit"><input id="post_status_pending" name="post_status" type="radio" value="pending" <?php checked($post->post_status, 'pending'); ?> /> <?php _e('Pending Review') ?></label> - <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label> - <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div> -</fieldset> - -<?php if ( current_user_can('edit_posts') ) : ?> -<fieldset id="posttimestampdiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Post Timestamp'); ?></h3> -<div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div> -</fieldset> <?php endif; ?> +<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> +<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option> +</select> +</p> +<?php if ( current_user_can( 'publish_posts' ) ) : ?> +<p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex="4" /> <?php _e('Keep this post private') ?></label></p> +<?php endif; ?> <?php -$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM -if ( $post->post_author && !in_array($post->post_author, $authors) ) - $authors[] = $post->post_author; -if ( $authors && count( $authors ) > 1 ) : +if ($post_ID) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + $stamp = __('Scheduled for:<br />%1$s at %2$s'); + } else if ( 'publish' == $post->post_status ) { // already published + $stamp = __('Published on:<br />%1$s at %2$s'); + } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified + $stamp = __('Publish immediately'); + } else { // draft, 1 or more saves, date specified + $stamp = __('Publish on:<br />%1$s at %2$s'); + } + $date = mysql2date(get_option('date_format'), $post->post_date); + $time = mysql2date(get_option('time_format'), $post->post_date); +} else { // draft (no saves, and thus no date specified) + $stamp = __('Publish immediately'); + $date = mysql2date(get_option('date_format'), current_time('mysql')); + $time = mysql2date(get_option('time_format'), current_time('mysql')); +} ?> -<fieldset id="authordiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Post Author'); ?></h3> -<div class="dbx-content"> -<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?> -</div> -</fieldset> -<?php endif; ?> +<?php if ( current_user_can( 'publish_posts' ) ) : // Contributors don't get to choose the date of publish ?> +<p class="curtime"><?php printf($stamp, $date, $time); ?> + <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p> -<?php do_action('dbx_post_sidebar'); ?> +<div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div> +<?php endif; ?> </div> -</div> - -<fieldset id="titlediv"> - <legend><?php _e('Title') ?></legend> - <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" /></div> -</fieldset> - -<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> -<legend><?php _e('Post') ?> - -<?php if ( 'publish' == $post->post_status ) { ?> -<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" class="view-link" target="_blank"><?php _e('View »'); ?></a> -<?php } elseif ( 'edit' == $action ) { ?> -<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" class="view-link" target="_blank"><?php _e('Preview »'); ?></a> -<?php } ?> -</legend> - - <?php the_editor($post->post_content); ?> -</fieldset> - -<?php echo $form_pingback ?> -<?php echo $form_prevstatus ?> - -<fieldset id="tagdiv"> - <legend><?php _e('Tags (separate multiple tags with commas: cats, pet food, dogs)'); ?></legend> - <div><input type="text" name="tags_input" class="tags-input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></div> -</fieldset> <p class="submit"> -<span id="autosave"></span> -<?php echo $saveasdraft; ?> -<input type="submit" name="submit" value="<?php _e('Save'); ?>" style="font-weight: bold;" tabindex="4" /> +<input type="submit" name="save" id="save-post" value="<?php _e('Save'); ?>" tabindex="4" class="button button-highlighted" /> <?php if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) { ?> <?php if ( current_user_can('publish_posts') ) : ?> - <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" /> + <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" /> <?php else : ?> - <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" /> + <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" /> <?php endif; ?> <?php } -?> -<input name="referredby" type="hidden" id="referredby" value="<?php -if ( !empty($_REQUEST['popupurl']) ) - echo clean_url(stripslashes($_REQUEST['popupurl'])); -else if ( url_to_postid(wp_get_referer()) == $post_ID ) - echo 'redo'; -else - echo clean_url(stripslashes(wp_get_referer())); -?>" /></p> - -<?php do_action('edit_form_advanced'); ?> -<?php -if (current_user_can('upload_files')) { - $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); - $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&tab=upload&post_id=$uploading_iframe_ID", 'inlineuploading'); - $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); - if ( false != $uploading_iframe_src ) - echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>'; +if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) ) + echo "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post_ID", 'delete-post_' . $post_ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete post') . "</a>"; +?> +<br class="clear" /> +<?php if ($post_ID): ?> +<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { + $last_user = get_userdata($last_id); + printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); +} else { + printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); } ?> +<br class="clear" /> +<?php endif; ?> +<span id="autosave"></span> +</p> + +<div class="side-info"> +<h5><?php _e('Related') ?></h5> + +<ul> +<?php if ($post_ID): ?> +<li><a href="edit.php?p=<?php echo $post_ID ?>"><?php _e('See Comments on this Post') ?></a></li> +<?php endif; ?> +<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li> +<li><a href="edit.php"><?php _e('Manage All Posts') ?></a></li> +<li><a href="categories.php"><?php _e('Manage All Categories') ?></a></li> +<li><a href="edit-tags.php"><?php _e('Manage All Tags') ?></a></li> +<li><a href="edit.php?post_status=draft"><?php _e('View Drafts'); ?></a></li> +<?php do_action('post_relatedlinks_list'); ?> +</ul> +</div> -<div id="advancedstuff" class="dbx-group" > +<?php do_action('submitpost_box'); ?> +</div> -<div class="dbx-b-ox-wrapper"> -<fieldset id="postexcerpt" class="dbx-box"> -<div class="dbx-h-andle-wrapper"> -<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3> +<div id="post-body"> +<div id="titlediv"> +<h3><?php _e('Title') ?></h3> +<div id="titlewrap"> + <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" autocomplete="off" /> </div> -<div class="dbx-c-ontent-wrapper"> -<div class="dbx-content"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div> +<div class="inside"> +<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?> + <div id="edit-slug-box"> +<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) : + echo $sample_permalink_html; +endif; ?> + </div> </div> -</fieldset> </div> -<div class="dbx-b-ox-wrapper"> -<fieldset id="trackbacksdiv" class="dbx-box"> -<div class="dbx-h-andle-wrapper"> -<h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3> +<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"> +<h3><?php _e('Post') ?></h3> +<?php the_editor($post->post_content); ?> +<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?> +<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> +<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?> +<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?> +</div> + +<?php echo $form_pingback ?> +<?php echo $form_prevstatus ?> + +<div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>"> +<h3><?php _e('Tags'); ?></h3> +<div class="inside"> +<p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p> +<div id="tagchecklist"></div> +</div> +</div> + +<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>"> +<h3><?php _e('Categories') ?></h3> +<div class="inside"> + +<div id="category-adder" class="wp-hidden-children"> + <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> + <p id="category-add" class="wp-hidden-child"> + <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" /> + <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> + <input type="button" id="category-add-sumbit" class="add:categorychecklist:categorydiv button" value="<?php _e( 'Add' ); ?>" tabindex="3" /> + <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?> + <span id="category-ajax-response"></span> + </p> +</div> + +<ul id="category-tabs"> + <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li> + <li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li> +</ul> + +<div id="categories-all" class="ui-tabs-panel"> + <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> + <?php dropdown_categories(); ?> + </ul> +</div> + +<div id="categories-pop" class="ui-tabs-panel" style="display: none;"> + <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" > + <?php wp_popular_terms_checklist('category'); ?> + </ul> +</div> + +</div> +</div> + +<?php do_meta_boxes('post', 'normal', $post); ?> + +<?php do_action('edit_form_advanced'); ?> + +<h2><?php _e('Advanced Options'); ?></h2> + +<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>"> +<h3><?php _e('Excerpt') ?></h3> +<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea> +<p><?php _e('Excerpts are optional hand-crafted summaries of your content. You can <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">use them in your template</a>'); ?></p> +</div> </div> -<div class="dbx-c-ontent-wrapper"> -<div class="dbx-content"><?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?> (<?php _e('Separate multiple URLs with spaces'); ?>) + +<div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv', 'post'); ?>"> +<h3><?php _e('Trackbacks') ?></h3> +<div class="inside"> +<p><?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p> +<p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress blogs they’ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p> <?php if ( ! empty($pings) ) echo $pings; ?> </div> </div> -</fieldset> -</div> -<div class="dbx-b-ox-wrapper"> -<fieldset id="postcustom" class="dbx-box"> -<div class="dbx-h-andle-wrapper"> -<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3> -</div> -<div class="dbx-c-ontent-wrapper"> -<div id="postcustomstuff" class="dbx-content"> +<div id="postcustom" class="postbox <?php echo postbox_classes('postcustom', 'post'); ?>"> +<h3><?php _e('Custom Fields') ?></h3> +<div class="inside"> +<div id="postcustomstuff"> <table cellpadding="3"> <?php $metadata = has_meta($post_ID); @@ -246,20 +289,65 @@ list_meta($metadata); ?> <div id="ajax-response"></div> </div> +<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p> </div> -</fieldset> </div> <?php do_action('dbx_post_advanced'); ?> +<div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv', 'post'); ?>"> +<h3><?php _e('Comments & Pings') ?></h3> +<div class="inside"> +<input name="advanced_view" type="hidden" value="1" /> +<p><label for="comment_status" class="selectit"> +<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> +<?php _e('Allow Comments') ?></label></p> +<p><label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label></p> +<p><?php _e('These settings apply to this post only. “Pings” are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p> +</div> </div> -<?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?> -<input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php echo ( 'draft' == $post->post_status ) ? __('Delete this draft') : __('Delete this post'); ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> /> +<div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv', 'post'); ?>"> +<h3><?php _e('Password Protect This Post') ?></h3> +<div class="inside"> +<p><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p> +<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p> +</div> +</div> + +<div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv', 'post'); ?>"> +<h3><?php _e('Post Slug') ?></h3> +<div class="inside"> +<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /> +</div> +</div> + +<?php +$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM +if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; +if ( $authors && count( $authors ) > 1 ) : +?> +<div id="authordiv" class="postbox <?php echo postbox_classes('authordiv', 'post'); ?>"> +<h3><?php _e('Post Author'); ?></h3> +<div class="inside"> +<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?> +</div> +</div> <?php endif; ?> +<?php do_meta_boxes('post', 'advanced', $post); ?> + +<?php do_action('dbx_post_sidebar'); ?> +</div> </div> </div> </form> + +<?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?> +<script type="text/javascript"> +try{document.post.title.focus();}catch(e){} +</script> +<?php endif; ?> diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php index 2f06909..f0baaee 100644 --- a/wp-admin/edit-form-comment.php +++ b/wp-admin/edit-form-comment.php @@ -1,81 +1,107 @@ <?php -$submitbutton_text = __('Edit Comment »'); +$submitbutton_text = __('Edit Comment'); $toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID); $form_action = 'editedcomment'; $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='" . $comment->comment_post_ID; ?> <form name="post" action="comment.php" method="post" id="post"> -<h2><?php echo $toprow_title; ?></h2> <?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?> <div class="wrap"> +<h2><?php echo $toprow_title; ?></h2> <input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> <input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' /> -<script type="text/javascript"> -function focusit() { // focus on first input field - document.post.name.focus(); -} -addLoadEvent(focusit); -</script> -<fieldset id="namediv"> - <legend><label for="name"><?php _e('Name:') ?></label></legend> - <div> - <input type="text" name="newcomment_author" size="25" value="<?php echo attribute_escape( $comment->comment_author ); ?>" tabindex="1" id="name" /> - </div> -</fieldset> -<fieldset id="emaildiv"> - <legend><label for="email"><?php _e('E-mail:') ?></label></legend> - <div> - <input type="text" name="newcomment_author_email" size="20" value="<?php echo attribute_escape( $comment->comment_author_email ); ?>" tabindex="2" id="email" /> - </div> -</fieldset> -<fieldset id="uridiv"> - <legend><label for="newcomment_author_url"><?php _e('URL:') ?></label></legend> - <div> - <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="2" /> - </div> -</fieldset> - -<fieldset style="clear: both;"> - <legend><?php _e('Comment') ?></legend> - <?php the_editor($comment->comment_content, 'content', 'newcomment_author_url'); ?> -</fieldset> - -<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" /> - <input name="referredby" type="hidden" id="referredby" value="<?php echo wp_get_referer(); ?>" /> +<div id="poststuff"> + +<div class="submitbox" id="submitcomment"> + +<div id="previewview"> +<a href="<?php echo get_comment_link(); ?>" target="_blank"><?php _e('View this Comment'); ?></a> +</div> + +<div class="inside"> + +<p><strong><?php _e('Approval Status') ?></strong></p> +<p> +<select name='comment_status'> +<option<?php selected( $comment->comment_approved, '1' ); ?> value='1'><?php _e('Approved') ?></option> +<option<?php selected( $comment->comment_approved, '0' ); ?> value='0'><?php _e('Moderated') ?></option> +<option<?php selected( $comment->comment_approved, 'spam' ); ?> value='spam'><?php _e('Spam') ?></option> +</select> </p> +<?php +$stamp = __('%1$s at %2$s'); +$date = mysql2date(get_option('date_format'), $comment->comment_date); +$time = mysql2date(get_option('time_format'), $comment->comment_date); +?> +<p class="curtime"><?php printf($stamp, $date, $time); ?> + <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a></p> + +<div id='timestampdiv' class='hide-if-js'><?php touch_time(('editcomment' == $action), 0, 5); ?></div> + </div> -<div class="wrap"> -<h2><?php _e('Advanced'); ?></h2> - -<table width="100%" cellspacing="2" cellpadding="5" class="editform"> - <tr> - <th scope="row" valign="top"><?php _e('Comment Status') ?>:</th> - <td><label for="comment_status_approved" class="selectit"><input id="comment_status_approved" name="comment_status" type="radio" value="1" <?php checked($comment->comment_approved, '1'); ?> tabindex="4" /> <?php _e('Approved') ?></label> - <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> tabindex="4" /> <?php _e('Moderated') ?></label> - <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> tabindex="4" /> <?php _e('Spam') ?></label></td> - </tr> - -<?php if ( current_user_can('edit_posts') ) : ?> - <tr> - <th scope="row" valign="top"><?php _e('Edit time'); ?>:</th> - <td><?php touch_time(('editcomment' == $action), 0, 5); ?> </td> - </tr> -<?php endif; ?> - - <tr> - <th scope="row" valign="top"> </th> - <td><input name="deletecomment" class="button delete" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ) { document.forms.post._wpnonce.value = '" . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) . "'; return true; } return false;\""; ?> /> - <input type="hidden" name="c" value="<?php echo $comment->comment_ID ?>" /> - <input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" /> - <input type="hidden" name="noredir" value="1" /> - </td> - </tr> -</table> +<p class="submit"> +<input type="submit" name="save" value="<?php _e('Save'); ?>" tabindex="4" class="button button-highlighted" /> +<?php +echo "<a class='submitdelete' href='" . wp_nonce_url("comment.php?action=deletecomment&c=$comment->comment_ID", 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . js_escape(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ) { return true;}return false;\">" . __('Delete comment') . "</a>"; +?> +</p> + +<div class="side-info"> +<h5><?php _e('Related') ?></h5> + +<ul> +<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li> +<li><a href="edit-comments.php?comment_status=moderated"><?php _e('Moderate Comments') ?></a></li> +<?php do_action('comment_relatedlinks_list'); ?> +</ul> +</div> +<?php do_action('submitcomment_box'); ?> +</div> + +<div id="post-body"> +<div id="namediv" class="stuffbox"> +<h3><?php _e('Name') ?></h3> +<div class="inside"> +<input type="text" name="newcomment_author" size="30" value="<?php echo attribute_escape( $comment->comment_author ); ?>" tabindex="1" id="name" /> +</div> +</div> +<div id="emaildiv" class="stuffbox"> +<h3><?php _e('E-mail') ?></h3> +<div class="inside"> +<input type="text" name="newcomment_author_email" size="30" value="<?php echo attribute_escape( $comment->comment_author_email ); ?>" tabindex="2" id="email" /> +</div> +</div> + +<div id="uridiv" class="stuffbox"> +<h3><?php _e('URL') ?></h3> +<div class="inside"> +<input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="3" /> +</div> +</div> + +<div id="postdiv" class="postarea"> +<h3><?php _e('Comment') ?></h3> +<?php the_editor($comment->comment_content, 'content', 'newcomment_author_url', false, 4); ?> +<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> +</div> + +<?php do_meta_boxes('comment', 'normal', $comment); ?> + +<input type="hidden" name="c" value="<?php echo $comment->comment_ID ?>" /> +<input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" /> +<input name="referredby" type="hidden" id="referredby" value="<?php echo wp_get_referer(); ?>" /> +<input type="hidden" name="noredir" value="1" /> +</div> +</div> </div> </form> + +<script type="text/javascript"> +try{document.post.name.focus();}catch(e){} +</script> diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php index 00e4932..18997e4 100644 --- a/wp-admin/edit-form.php +++ b/wp-admin/edit-form.php @@ -6,18 +6,9 @@ <?php if (isset($mode) && 'bookmarklet' == $mode) : ?> <input type="hidden" name="mode" value="bookmarklet" /> <?php endif; ?> -<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> +<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> <input type="hidden" name="action" value='post' /> -<script type="text/javascript"> -<!-- -function focusit() { // focus on first input field - document.getElementById('title').focus(); -} -addLoadEvent(focusit); -//--> -</script> - <div id="poststuff"> <fieldset id="titlediv"> <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend> @@ -39,6 +30,7 @@ addLoadEvent(focusit); } ?> <div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div> +<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?> </fieldset> @@ -57,11 +49,11 @@ edCanvas = document.getElementById('content'); <input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" /> <?php if ( current_user_can('edit_posts') ) : ?> - <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="<?php _e('Publish') ?>" /> + <input name="publish" type="submit" id="publish" tabindex="6" value="<?php _e('Publish') ?>" class="button button-highlighted" /> <?php endif; ?> <?php if ('bookmarklet' != $mode) { - echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing »') . '" />'; + echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing') . '" />'; } ?> <input name="referredby" type="hidden" id="referredby" value="<?php if ( $refby = wp_get_referer() ) echo urlencode($refby); ?>" /> </p> @@ -71,4 +63,7 @@ edCanvas = document.getElementById('content'); </div> </form> +<script type="text/javascript"> +try{document.getElementById('title').focus();}catch(e){} +</script> </div> diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php index 3e05f5a..b8dfebc 100644 --- a/wp-admin/edit-link-categories.php +++ b/wp-admin/edit-link-categories.php @@ -1,10 +1,43 @@ <?php require_once('admin.php'); -$title = __('Categories'); -$parent_file = 'link-manager.php'; +// Handle bulk deletes +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { + check_admin_referer('bulk-link-categories'); + + if ( !current_user_can('manage_categories') ) + wp_die(__('Cheatin’ uh?')); + + foreach( (array) $_GET['delete'] as $cat_ID ) { + $cat_name = get_term_field('name', $cat_ID, 'link_category'); + + // Don't delete the default cats. + if ( $cat_ID == get_option('default_link_category') ) + wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); + + wp_delete_term($cat_ID, 'link_category'); + } + + $location = 'edit-link-categories.php'; + if ( $referer = wp_get_referer() ) { + if ( false !== strpos($referer, 'edit-link-categories.php') ) + $location = $referer; + } + + $location = add_query_arg('message', 6, $location); + wp_redirect($location); + exit(); +} elseif ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; +} + +$title = __('Link Categories'); +$parent_file = 'edit.php'; + +wp_enqueue_script( 'admin-categories' ); +wp_enqueue_script('admin-forms'); -//wp_enqueue_script( 'admin-categories' ); TODO: Fix AJAX require_once ('admin-header.php'); $messages[1] = __('Category added.'); @@ -12,58 +45,76 @@ $messages[2] = __('Category deleted.'); $messages[3] = __('Category updated.'); $messages[4] = __('Category not added.'); $messages[5] = __('Category not updated.'); +$messages[6] = __('Categories deleted.'); -function link_cat_row($category) { - global $class; +if (isset($_GET['message'])) : ?> +<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); +endif; ?> - if ( current_user_can( 'manage_categories' ) ) { - $edit = "<a href='link-category.php?action=edit&cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>"; - $default_cat_id = (int) get_option( 'default_link_category' ); +<div class="wrap"> - if ( $category->term_id != $default_cat_id ) - $edit .= "<td><a href='" . wp_nonce_url( "link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_term_field( 'name', $default_cat_id, 'link_category' ))) . "' );\" class='delete'>".__( 'Delete' )."</a>"; - else - $edit .= "<td style='text-align:center'>".__( "Default" ); - } else { - $edit = ''; - } +<form id="posts-filter" action="" method="get"> +<?php if ( current_user_can('manage_categories') ) : ?> + <h2><?php printf(__('Manage Link Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2> +<?php else : ?> + <h2><?php _e('Manage Link Categories') ?> </h2> +<?php endif; ?> - $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" /> + <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" /> +</p> - $category->count = number_format_i18n( $category->count ); - $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; - return "<tr id='cat-$category->term_id'$class> - <th scope='row' style='text-align: center'>$category->term_id</th> - <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td> - <td>$category->description</td> - <td align='center'>$count</td> - <td>$edit</td>\n\t</tr>\n"; -} +<br class="clear" /> + +<div class="tablenav"> + +<?php +$pagenum = absint( $_GET['pagenum'] ); +if ( empty($pagenum) ) + $pagenum = 1; +if( !$catsperpage || $catsperpage < 0 ) + $catsperpage = 20; + +$page_links = paginate_links( array( + 'base' => add_query_arg( 'pagenum', '%#%' ), + 'format' => '', + 'total' => ceil(wp_count_terms('link_category') / $catsperpage), + 'current' => $pagenum +)); + +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; ?> -<?php if (isset($_GET['message'])) : ?> -<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> -<?php endif; ?> +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php wp_nonce_field('bulk-link-categories'); ?> +</div> + +<br class="clear" /> +</div> + +<br class="clear" /> -<div class="wrap"> -<?php if ( current_user_can('manage_categories') ) : ?> - <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2> -<?php else : ?> - <h2><?php _e('Categories') ?> </h2> -<?php endif; ?> <table class="widefat"> <thead> <tr> - <th scope="col" style="text-align: center"><?php _e('ID') ?></th> + <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> <th scope="col"><?php _e('Name') ?></th> <th scope="col"><?php _e('Description') ?></th> - <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th> - <th colspan="2" style="text-align: center"><?php _e('Action') ?></th> + <th scope="col" class="num" style="width: 90px;"><?php _e('Links') ?></th> </tr> </thead> - <tbody id="the-list"> + <tbody id="the-list" class="list:link-cat"> <?php -$categories = get_terms( 'link_category', 'hide_empty=0' ); +$start = ($pagenum - 1) * $catsperpage; +$args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0); +if ( !empty( $_GET['s'] ) ) + $args['search'] = $_GET['s']; + +$categories = get_terms( 'link_category', $args ); if ( $categories ) { $output = ''; foreach ( $categories as $category ) { @@ -78,6 +129,17 @@ if ( $categories ) { ?> </tbody> </table> +</form> + +<div class="tablenav"> + +<?php +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; +?> +<br class="clear" /> +</div> +<br class="clear" /> </div> diff --git a/wp-admin/edit-link-category-form.php b/wp-admin/edit-link-category-form.php index 51bbcda..517f574 100644 --- a/wp-admin/edit-link-category-form.php +++ b/wp-admin/edit-link-category-form.php @@ -1,15 +1,15 @@ <?php if ( ! empty($cat_ID) ) { $heading = __('Edit Category'); - $submit_text = __('Edit Category »'); - $form = '<form name="editcat" id="editcat" method="post" action="link-category.php">'; + $submit_text = __('Edit Category'); + $form = '<form name="editcat" id="editcat" method="post" action="link-category.php" class="validate">'; $action = 'editedcat'; $nonce_action = 'update-link-category_' . $cat_ID; do_action('edit_link_category_form_pre', $category); } else { $heading = __('Add Category'); - $submit_text = __('Add Category »'); - $form = '<form name="addcat" id="addcat" method="post" action="link-category.php">'; + $submit_text = __('Add Category'); + $form = '<form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">'; $action = 'addcat'; $nonce_action = 'add-link-category'; do_action('add_link_category_form_pre', $category); @@ -22,22 +22,18 @@ if ( ! empty($cat_ID) ) { <?php echo $form ?> <input type="hidden" name="action" value="<?php echo $action ?>" /> <input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" /> -<?php wp_nonce_field($nonce_action); ?> - <table class="editform" width="100%" cellspacing="2" cellpadding="5"> - <tr> - <th width="33%" scope="row" valign="top"><label for="name"><?php _e('Category name:') ?></label></th> - <td width="67%"><input name="name" id="name" type="text" value="<?php echo $category->name; ?>" size="40" /></td> +<?php wp_original_referer_field(true, 'previous'); wp_nonce_field($nonce_action); ?> + <table class="form-table"> + <tr class="form-field form-required"> + <th scope="row" valign="top"><label for="name"><?php _e('Category name') ?></label></th> + <td><input name="name" id="name" type="text" value="<?php echo $category->name; ?>" size="40" /></td> </tr> - <tr> - <th scope="row" valign="top"><label for="slug"><?php _e('Category slug:') ?></label></th> - <td><input name="slug" id="slug" type="text" value="<?php echo $category->slug; ?>" size="40" /></td> - </tr> - <tr> - <th scope="row" valign="top"><label for="description"><?php _e('Description: (optional)') ?></label></th> + <tr class="form-field"> + <th scope="row" valign="top"><label for="description"><?php _e('Description (optional)') ?></label></th> <td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo $category->description; ?></textarea></td> </tr> </table> -<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p> +<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p> <?php do_action('edit_link_category_form', $category); ?> </form> </div> diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php index e281d30..a68c6da 100644 --- a/wp-admin/edit-link-form.php +++ b/wp-admin/edit-link-form.php @@ -1,17 +1,17 @@ <?php if ( ! empty($link_id) ) { $heading = __('Edit Link'); - $submit_text = __('Save Changes »'); + $submit_text = __('Save Changes'); $form = '<form name="editlink" id="editlink" method="post" action="link.php">'; $nonce_action = 'update-bookmark_' . $link_id; } else { $heading = __('Add Link'); - $submit_text = __('Add Link »'); + $submit_text = __('Add Link'); $form = '<form name="addlink" id="addlink" method="post" action="link.php">'; $nonce_action = 'add-bookmark'; } -function xfn_check($class, $value = '', $type = 'check') { +function xfn_check($class, $value = '', $deprecated = '') { global $link; $link_rel = $link->link_rel; @@ -30,86 +30,138 @@ function xfn_check($class, $value = '', $type = 'check') { } ?> -<div class="wrap"> -<h2><?php echo $heading ?></h2> <?php echo $form ?> <?php wp_nonce_field($nonce_action); ?> +<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> + +<div class="wrap"> +<h2><?php echo $heading; ?></h2> <div id="poststuff"> -<div id="moremeta"> -<div id="grabit" class="dbx-group"> - -<fieldset id="categorydiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Categories') ?></h3> -<div class="dbx-content"> -<p id="jaxcat"></p> -<ul id="linkcategorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul> + +<div class="submitbox" id="submitlink"> + +<div id="previewview"> +<?php if ( !empty($link_id) ) { ?> +<a href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a> +<?php } ?> +</div> + +<div class="inside"> +<p><label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label></p> +</div> + +<p class="submit"> +<input type="submit" class="button button-highlighted" name="save" value="<?php _e('Save'); ?>" tabindex="4" /> +<?php +if ( ( 'edit' == $action) && current_user_can('manage_links') ) + echo "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link_id", 'delete-bookmark_' . $link_id) . "' onclick=\"if ( confirm('" . js_escape( sprintf( __("You are about to delete this link '%s'\n'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete link') . "</a>"; +?> +</p> + +<div class="side-info"> +<h5><?php _e('Related') ?></h5> + +<ul> +<li><a href="link-manager.php"><?php _e('Manage All Links') ?></a></li> +<li><a href="edit-link-categories.php"><?php _e('Manage All Link Categories') ?></a></li> +<li><a href="link-import.php"><?php _e('Import Links') ?></a></li> +<?php do_action('link_relatedlinks_list'); ?> +</ul> +</div> +<?php do_action('submitlink_box'); ?> +</div> + +<div id="post-body"> +<div id="namediv" class="stuffbox"> +<h3><?php _e('Name') ?></h3> +<div class="inside"> + <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo $link->link_name; ?>" id="link_name" /><br /> + <?php _e('Example: Nifty blogging software'); ?> +</div> </div> -</fieldset> -<fieldset class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Target') ?></h3> -<div class="dbx-content"> +<div id="addressdiv" class="stuffbox"> +<h3><?php _e('Web Address') ?></h3> +<div class="inside"> + <input type="text" name="link_url" size="30" tabindex="1" value="<?php echo $link->link_url; ?>" id="link_url" /><br /> + <?php _e('Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>'); ?> +</div> +</div> + +<div id="descriptiondiv" class="stuffbox"> +<h3><?php _e('Description') ?></h3> +<div class="inside"> + <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo $link->link_description; ?>" id="link_description" /><br /> + <?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?> +</div> +</div> + +<div id="linkcategorydiv" class="postbox <?php echo postbox_classes('linkcategorydiv', 'link'); ?>"> +<h3><?php _e('Categories') ?></h3> +<div class="inside"> + +<div id="category-adder" class="wp-hidden-children"> + <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4> + <p id="link-category-add" class="wp-hidden-child"> + <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" /> + <input type="button" id="category-add-sumbit" class="add:categorychecklist:linkcategorydiv button" value="<?php _e( 'Add' ); ?>" /> + <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?> + <span id="category-ajax-response"></span> + </p> +</div> + +<ul id="category-tabs"> + <li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li> + <li class="wp-no-js-hidden"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li> +</ul> + +<div id="categories-all" class="ui-tabs-panel"> + <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> + <?php dropdown_link_categories(); ?> + </ul> +</div> + +<div id="categories-pop" class="ui-tabs-panel" style="display: none;"> + <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> + <?php wp_popular_terms_checklist('link_category'); ?> + </ul> +</div> + +</div> +</div> + +<?php do_meta_boxes('link', 'normal', $link); ?> + +<h2><?php _e('Advanced Options'); ?></h2> + +<div id="linktargetdiv" class="postbox <?php echo postbox_classes('linktargetdiv', 'link'); ?>"> +<h3><?php _e('Target') ?></h3> +<div class="inside"> <label for="link_target_blank" class="selectit"> <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> -<code>_blank</code></label> +<code>_blank</code></label><br /> <label for="link_target_top" class="selectit"> <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> -<code>_top</code></label> +<code>_top</code></label><br /> <label for="link_target_none" class="selectit"> <input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> /> <?php _e('none') ?></label> +<p><?php _e('Choose the frame your link targets. Essentially this means if you choose <code>_blank</code> your link will open in a new window.'); ?></p> </div> -</fieldset> - -<fieldset class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Visible') ?></h3> -<div class="dbx-content"> -<label for="link_visible_yes" class="selectit"> -<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" /> -<?php _e('Yes') ?></label> -<label for="link_visible_no" class="selectit"> -<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" /> -<?php _e('No') ?></label> </div> -</fieldset> -</div> -</div> - -<table class="editform" width="100%" cellspacing="2" cellpadding="5"> -<tr> -<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th> -<td><input type="text" name="link_name" id="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td> -</tr> -<tr> -<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th> -<td width="80%"><input type="text" name="link_url" id="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td> -</tr> -<tr> -<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th> -<td><input type="text" name="link_description" id="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td> -</tr> -</table> - -<p class="submit"> -<input type="submit" name="submit" value="<?php echo $submit_text ?>" /> -</p> - -<div id="advancedstuff" class="dbx-group" > - -<fieldset id="xfn" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3> -<div class="dbx-content"> -<table class="editform" width="100%" cellspacing="2" cellpadding="5"> +<div id="linkxfndiv" class="postbox <?php echo postbox_classes('linkxfndiv', 'link'); ?>"> +<h3><?php _e('Link Relationship (XFN)') ?></h3> +<div class="inside"> +<table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5"> <tr> - <th width="20%" scope="row"><?php _e('rel:') ?></th> - <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> + <th style="width: 20%;" scope="row"><?php _e('rel:') ?></th> + <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> </tr> <tr> - <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th> - <td> - <table cellpadding="3" cellspacing="5"> + <td colspan="2"> + <table cellpadding="3" cellspacing="5" class="form-table"> <tr> <th scope="row"> <?php _e('identity') ?> </th> <td> @@ -208,28 +260,29 @@ function xfn_check($class, $value = '', $type = 'check') { </td> </tr> </table> +<p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p> +</div> </div> -</fieldset> -<fieldset id="advanced" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Advanced') ?></h3> -<div class="dbx-content"> -<table class="editform" width="100%" cellspacing="2" cellpadding="5"> - <tr> - <th width="20%" scope="row"><?php _e('Image Address:') ?></th> - <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> +<div id="linkadvanceddiv" class="postbox <?php echo postbox_classes('linkadvanceddiv', 'link'); ?>"> +<h3><?php _e('Advanced') ?></h3> +<div class="inside"> +<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5"> + <tr class="form-field"> + <th valign="top" scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th> + <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> </tr> - <tr> - <th scope="row"><?php _e('RSS Address:') ?> </th> + <tr class="form-field"> + <th valign="top" scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th> <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td> </tr> - <tr> - <th scope="row"><?php _e('Notes:') ?></th> - <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> + <tr class="form-field"> + <th valign="top" scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th> + <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> </tr> - <tr> - <th scope="row"><?php _e('Rating:') ?></th> - <td><select name="link_rating" size="1"> + <tr class="form-field"> + <th valign="top" scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th> + <td><select name="link_rating" id="link_rating" size="1"> <?php for ($r = 0; $r < 10; $r++) { echo(' <option value="'.$r.'" '); @@ -242,9 +295,10 @@ function xfn_check($class, $value = '', $type = 'check') { </tr> </table> </div> -</fieldset> </div> +<?php do_meta_boxes('link', 'advanced', $link); ?> + <?php if ( $link_id ) : ?> <input type="hidden" name="action" value="save" /> <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> @@ -253,6 +307,10 @@ function xfn_check($class, $value = '', $type = 'check') { <?php else: ?> <input type="hidden" name="action" value="add" /> <?php endif; ?> + </div> -</form> </div> + +</div> + +</form> diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index e3a039e..790a40e 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -2,8 +2,18 @@ <div class="wrap"> <h2 id="write-post"><?php _e('Write Page'); ?></h2> <?php +if ( isset($_GET['message']) ) + $_GET['message'] = absint( $_GET['message'] ); +$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); +$messages[2] = __('Custom field updated.'); +$messages[3] = __('Custom field deleted.'); +$messages[4] = __('Page updated.'); +?> +<?php if (isset($_GET['message'])) : ?> +<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> +<?php endif; -if (0 == $post_ID) { +if (!isset($post_ID) || 0 == $post_ID) { $form_action = 'post'; $nonce_action = 'add-page'; $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() @@ -25,160 +35,166 @@ if ( 0 != $post_ID && $sendto == get_permalink($post_ID) ) ?> <form name="post" action="page.php" method="post" id="post"> +<div class="wrap"> +<h2><?php _e('Write Page') ?></h2> <?php wp_nonce_field($nonce_action); -if (isset($mode) && 'bookmarklet' == $mode) { +if (isset($mode) && 'bookmarklet' == $mode) echo '<input type="hidden" name="mode" value="bookmarklet" />'; -} ?> -<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> +<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" /> <input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' /> <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" /> <?php echo $form_extra ?> -<input type="hidden" id="post_type" name="post_type" value="page" /> +<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" /> +<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" /> +<input name="referredby" type="hidden" id="referredby" value="<?php +if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false ) + echo 'redo'; +else + echo clean_url(stripslashes(wp_get_referer())); +?>" /> +<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?> -<script type="text/javascript"> -// <![CDATA[ -function focusit() { // focus on first input field - document.post.title.focus(); -} -addLoadEvent(focusit); -// ]]> -</script> <div id="poststuff"> -<div id="moremeta"> -<div id="grabit" class="dbx-group"> -<fieldset id="commentstatusdiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Discussion') ?></h3> -<div class="dbx-content"> -<input name="advanced_view" type="hidden" value="1" /> -<label for="comment_status" class="selectit"> -<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> -<?php _e('Allow Comments') ?></label> -<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label> -</div> -</fieldset> +<div class="submitbox" id="submitpage"> -<fieldset class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Status') ?></h3> -<div class="dbx-content"><?php if ( current_user_can('publish_pages') ) : ?> -<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label> -<?php endif; ?> - <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label> - <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div> -</fieldset> - -<fieldset id="passworddiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Password') ?></h3> -<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div> -</fieldset> - -<fieldset id="pageparent" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Parent') ?></h3> -<div class="dbx-content"><p><select name="parent_id"> -<option value='0'><?php _e('Main Page (no parent)'); ?></option> -<?php parent_dropdown($post->post_parent); ?> -</select></p> +<div id="previewview"> +<?php if ( 'publish' == $post->post_status ) { ?> +<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View this Page'); ?></a> +<?php } elseif ( 'edit' == $action ) { ?> +<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview this Page'); ?></a> +<?php } ?> </div> -</fieldset> -<?php if ( 0 != count( get_page_templates() ) ) { ?> -<fieldset id="pagetemplate" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Template') ?></h3> -<div class="dbx-content"><p><select name="page_template"> - <option value='default'><?php _e('Default Template'); ?></option> - <?php page_template_dropdown($post->page_template); ?> - </select></p> -</div> -</fieldset> -<?php } ?> +<div class="inside"> -<fieldset id="slugdiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Slug') ?></h3> -<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div> -</fieldset> +<p><strong><?php _e('Publish Status') ?></strong></p> +<p> +<select name='post_status' tabindex='4'> +<?php if ( current_user_can('publish_posts') ) : ?> +<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option> +<?php else: ?> +<option<?php selected( $post->post_status, 'private' ); ?> value='private'><?php _e('Published') ?></option> +<?php endif; ?> +<?php if ( 'future' == $post->post_status ) : ?> +<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Pending') ?></option> +<?php endif; ?> +<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> +<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option> +</select> +</p> -<?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?> -<fieldset id="authordiv" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Author'); ?></h3> -<div class="dbx-content"> -<select name="post_author_override" id="post_author_override"> +<p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex='4' /> <?php _e('Keep this page private') ?></label></p> <?php -foreach ($authors as $o) : -$o = get_userdata( $o->ID ); -if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; -else $selected = ''; -$o->ID = (int) $o->ID; -$o->display_name = wp_specialchars( $o->display_name ); -echo "<option value='$o->ID' $selected>$o->display_name</option>"; -endforeach; +if ($post_ID) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + $stamp = __('Scheduled for:<br />%1$s at %2$s'); + } else if ( 'publish' == $post->post_status ) { // already published + $stamp = __('Published on:<br />%1$s at %2$s'); + } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified + $stamp = __('Publish immediately'); + } else { // draft, 1 or more saves, date specified + $stamp = __('Publish on:<br />%1$s at %2$s'); + } + $date = mysql2date(get_option('date_format'), $post->post_date); + $time = mysql2date(get_option('time_format'), $post->post_date); +} else { // draft (no saves, and thus no date specified) + $stamp = __('Publish immediately'); + $date = mysql2date(get_option('date_format'), current_time('mysql')); + $time = mysql2date(get_option('time_format'), current_time('mysql')); +} ?> -</select> +<p class="curtime"><?php printf($stamp, $date, $time); ?> + <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p> + +<div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div> + </div> -</fieldset> + +<p class="submit"> +<input type="submit" name="save" class="button button-highlighted" value="<?php _e('Save'); ?>" tabindex="4" /> +<?php +if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) { +?> +<?php if ( current_user_can('publish_pages') ) : ?> + <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" /> +<?php else : ?> + <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" /> <?php endif; ?> +<?php +} -<fieldset id="pageorder" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Page Order') ?></h3> -<div class="dbx-content"><p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p></div> -</fieldset> +if ( ('edit' == $action) && current_user_can('delete_page', $post_ID) ) + echo "<a class='submitdelete' href='" . wp_nonce_url("page.php?action=delete&post=$post_ID", 'delete-page_' . $post_ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete page') . "</a>"; +?> +<br class="clear" /> +<?php if ($post_ID): ?> +<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) { + $last_user = get_userdata($last_id); + printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); +} else { + printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); +} +?> +<br class="clear" /> +<?php endif; ?> +<span id="autosave"></span> +</p> -<?php do_action('dbx_page_sidebar'); ?> +<div class="side-info"> +<h5><?php _e('Related') ?></h5> +<ul> +<?php if ($post_ID): ?> +<li><a href="edit-pages.php?page_id=<?php echo $post_ID ?>"><?php _e('See Comments on this Page') ?></a></li> +<?php endif; ?> +<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li> +<li><a href="edit-pages.php"><?php _e('Manage All Pages') ?></a></li> +<?php do_action('page_relatedlinks_list'); ?> +</ul> </div> +<?php do_action('submitpage_box'); ?> </div> -<fieldset id="titlediv"> - <legend><?php _e('Page Title') ?></legend> - <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div> -</fieldset> - - -<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> -<legend><?php _e('Page Content') ?> +<div id="post-body"> +<div id="titlediv"> +<h3><?php _e('Title') ?></h3> +<div id="titlewrap"> + <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" autocomplete="off" /> +</div> +<div class="inside"> +<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?> + <div id="edit-slug-box"> +<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) : + echo $sample_permalink_html; +endif; ?> + </div> +</div> +</div> -<?php if ( 'publish' == $post->post_status ) { ?> -<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('View »'); ?></a> -<?php } elseif ( 'edit' == $action ) { ?> -<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('Preview »'); ?></a> -<?php } ?> -</legend> - <?php the_editor($post->post_content); ?> -</fieldset> +<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"> +<h3><?php _e('Page') ?></h3> +<?php the_editor($post->post_content); ?> +<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?> +<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> +<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?> +<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?> +</div> -<p class="submit"> -<span id="autosave"></span> -<input name="save" type="submit" id="save" tabindex="3" value="<?php _e('Save and Continue Editing'); ?>" /> -<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" /> -<?php -if ('publish' != $post->post_status || 0 == $post_ID): -?> -<?php if ( current_user_can('publish_pages') ) : ?> - <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" /> -<?php endif; endif;?> -<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" /> -</p> +<?php do_meta_boxes('page', 'normal', $post); ?> <?php do_action('edit_page_form'); ?> -<?php -if (current_user_can('upload_files')) { - $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID); - $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&tab=upload&post_id=$uploading_iframe_ID", 'inlineuploading'); - $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); - if ( false != $uploading_iframe_src ) - echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>'; -} -?> - -<div id="advancedstuff" class="dbx-group"> +<h2><?php _e('Advanced Options'); ?></h2> -<fieldset id="postcustom" class="dbx-box"> -<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3> -<div id="postcustomstuff" class="dbx-content"> +<div id="pagepostcustom" class="postbox <?php echo postbox_classes('pagepostcustom', 'page'); ?>"> +<h3><?php _e('Custom Fields') ?></h3> +<div class="inside"> +<div id="postcustomstuff"> <table cellpadding="3"> <?php $metadata = has_meta($post_ID); @@ -189,21 +205,94 @@ list_meta($metadata); <?php meta_form(); ?> -</div> <div id="ajax-response"></div> -</fieldset> +</div> +<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p> +</div> +</div> + +<div id="pagecommentstatusdiv" class="postbox <?php echo postbox_classes('pagecommentstatusdiv', 'page'); ?>"> +<h3><?php _e('Comments & Pings') ?></h3> +<div class="inside"> +<input name="advanced_view" type="hidden" value="1" /> +<p><label for="comment_status" class="selectit"> +<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> +<?php _e('Allow Comments') ?></label></p> +<p><label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label></p> +<p><?php _e('These settings apply to this page only. “Pings” are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p> +</div> +</div> -<?php do_action('dbx_page_advanced'); ?> +<div id="pagepassworddiv" class="postbox <?php echo postbox_classes('pagepassworddiv', 'page'); ?>"> +<h3><?php _e('Password Protect This Page') ?></h3> +<div class="inside"> +<p><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p> +<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p> +</div> +</div> +<div id="pageslugdiv" class="postbox <?php echo postbox_classes('pageslugdiv', 'page'); ?>"> +<h3><?php _e('Page Slug') ?></h3> +<div class="inside"> +<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /> +</div> </div> -<?php if ('edit' == $action) : - $delete_nonce = wp_create_nonce( 'delete-page_' . $post_ID ); - if ( current_user_can('delete_page', $post->ID) ) ?> - <input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> /> +<div id="pageparentdiv" class="postbox <?php echo postbox_classes('pageparentdiv', 'page'); ?>"> +<h3><?php _e('Page Parent') ?></h3> +<div class="inside"> +<select name="parent_id"> +<option value='0'><?php _e('Main Page (no parent)'); ?></option> +<?php parent_dropdown($post->post_parent); ?> +</select> +<p><?php _e('You can arrange your pages in hierarchies, for example you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how deeply nested you can make pages.'); ?></p> +</div> +</div> + +<?php if ( 0 != count( get_page_templates() ) ) { ?> +<div id="pagetemplatediv" class="postbox <?php echo postbox_classes('pagetemplatediv', 'page'); ?>"> +<h3><?php _e('Page Template') ?></h3> +<div class="inside"> +<select name="page_template"> +<option value='default'><?php _e('Default Template'); ?></option> +<?php page_template_dropdown($post->page_template); ?> +</select> +<p><?php _e('Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them above.'); ?></p> +</div> +</div> +<?php } ?> + +<div id="pageorderdiv" class="postbox <?php echo postbox_classes('pageorderdiv', 'page'); ?>"> +<h3><?php _e('Page Order') ?></h3> +<div class="inside"> +<p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p> +<p><?php _e('Pages are usually ordered alphabetically, but you can put a number above to change the order pages appear in. (We know this is a little janky, it’ll be better in future releases.)'); ?></p> +</div> +</div> + +<?php +$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM +if ( $post->post_author && !in_array($post->post_author, $authors) ) + $authors[] = $post->post_author; +if ( $authors && count( $authors ) > 1 ) : +?> +<div id="pageauthordiv" class="postbox <?php echo postbox_classes('pageauthordiv', 'page'); ?>"> +<h3><?php _e('Page Author'); ?></h3> +<div class="inside"> +<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?> +</div> +</div> <?php endif; ?> + +<?php do_meta_boxes('page', 'advanced', $post); ?> + +</div> +</div> + </div> </form> -</div> +<script type="text/javascript"> +try{document.post.title.focus();}catch(e){} +</script> diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index f263348..ee4bee2 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -1,28 +1,68 @@ <?php require_once('admin.php'); + +// Handle bulk deletes +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { + check_admin_referer('bulk-pages'); + foreach( (array) $_GET['delete'] as $post_id_del ) { + $post_del = & get_post($post_id_del); + + if ( !current_user_can('delete_page', $post_id_del) ) + wp_die( __('You are not allowed to delete this page.') ); + + if ( $post_del->post_type == 'attachment' ) { + if ( ! wp_delete_attachment($post_id_del) ) + wp_die( __('Error in deleting...') ); + } else { + if ( !wp_delete_post($post_id_del) ) + wp_die( __('Error in deleting...') ); + } + } + + $sendback = wp_get_referer(); + if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page-new.php'; + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; + $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); + + wp_redirect($sendback); + exit(); +} elseif ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; +} + $title = __('Pages'); $parent_file = 'edit.php'; -wp_enqueue_script( 'listman' ); -require_once('admin-header.php'); +wp_enqueue_script('admin-forms'); $post_stati = array( // array( adj, noun ) - 'publish' => array(__('Published'), __('Published pages')), - 'draft' => array(__('Draft'), __('Draft pages')), - 'private' => array(__('Private'), __('Private pages')) - ); - - -$post_status_label = __('Pages'); + 'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')), + 'future' => array(__('Scheduled'), __('Scheduled pages'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), + 'pending' => array(__('Pending Review'), __('Pending pages'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')), + 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')), + 'private' => array(__('Private'), __('Private pages'), __ngettext_noop('Private (%s)', 'Private (%s)')) + ); + +$post_status_label = __('Manage Pages'); $post_status_q = ''; if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { $post_status_label = $post_stati[$_GET['post_status']][1]; $post_status_q = '&post_status=' . $_GET['post_status']; + $post_status_q .= '&perm=readable'; } -?> +$query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc"; -<div class="wrap"> +$query_str = apply_filters('manage_pages_query', $query_str); +wp($query_str); +if ( is_singular() ) + wp_enqueue_script( 'admin-comments' ); +require_once('admin-header.php'); + +?> +<div class="wrap"> +<form id="posts-filter" action="" method="get"> <h2><?php // Use $_GET instead of is_ since they can override each other $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : ''; @@ -34,38 +74,60 @@ if ( isset($_GET['author']) && $_GET['author'] ) { printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search ); ?></h2> -<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page »'); ?></a></p> +<ul class="subsubsub"> +<?php -<form name="searchform" id="searchform" action="" method="get"> - <fieldset><legend><?php _e('Search Terms…') ?></legend> - <input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" size="17" /> - </fieldset> +$avail_post_stati = get_available_post_statuses('page'); +$status_links = array(); +$num_posts = wp_count_posts('page', 'readable'); +$class = empty($_GET['post_status']) ? ' class="current"' : ''; +$status_links[] = "<li><a href=\"edit-pages.php\"$class>".__('All Pages')."</a>"; +foreach ( $post_stati as $status => $label ) { + $class = ''; - <fieldset><legend><?php _e('Page Type…'); ?></legend> - <select name='post_status'> - <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option> -<?php foreach ( $post_stati as $status => $label ) : ?> - <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option> -<?php endforeach; ?> - </select> - </fieldset> + if ( !in_array($status, $avail_post_stati) ) + continue; -<?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?> + if ( $status == $_GET['post_status'] ) + $class = ' class="current"'; - <fieldset><legend><?php _e('Author…'); ?></legend> - <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?> - </fieldset> + $status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" . + sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), number_format_i18n( $num_posts->$status ) ) . '</a>'; +} +echo implode(' |</li>', $status_links) . '</li>'; +unset($status_links); +?> +</ul> -<?php endif; ?> +<?php if ( isset($_GET['post_status'] ) ) : ?> +<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" /> +<?php +endif; +if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> +<div id="message" class="updated fade"><p><strong><?php _e('Your page has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View page'); ?></a> | <a href="page.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit page'); ?></a></p></div> +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); +endif; +?> - <input type="submit" id="post-query-submit" value="<?php _e('Filter »'); ?>" class="button" /> -</form> +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" /> + <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" /> +</p> + +<div class="tablenav"> + +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php wp_nonce_field('bulk-pages'); ?> +</div> + +<br class="clear" /> +</div> -<br style="clear:both;" /> +<br class="clear" /> <?php -wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc"); $all = !( $h2_search || $post_status_q ); @@ -74,29 +136,77 @@ if ($posts) { <table class="widefat"> <thead> <tr> - <th scope="col" style="text-align: center"><?php _e('ID') ?></th> - <th scope="col"><?php _e('Title') ?></th> - <th scope="col"><?php _e('Owner') ?></th> - <th scope="col"><?php _e('Updated') ?></th> - <th scope="col" colspan="3" style="text-align: center"><?php _e('Action'); ?></th> +<?php $posts_columns = wp_manage_pages_columns(); ?> +<?php foreach($posts_columns as $post_column_key => $column_display_name) { + if ( 'cb' === $post_column_key ) + $class = ' class="check-column"'; + elseif ( 'comments' === $post_column_key ) + $class = ' class="num"'; + else + $class = ''; +?> + <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th> +<?php } ?> </tr> </thead> - <tbody id="the-list"> -<?php page_rows(0, 0, $posts, $all); ?> + <tbody> + <?php page_rows($posts); ?> </tbody> </table> +</form> + <div id="ajax-response"></div> <?php } else { ?> +</form> <p><?php _e('No pages found.') ?></p> <?php } // end if ($posts) ?> -<h3><a href="page-new.php"><?php _e('Create New Page »'); ?></a></h3> +<div class="tablenav"> +<br class="clear" /> +</div> + +<?php + +if ( 1 == count($posts) && is_singular() ) : + + $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); + if ( $comments ) : + // Make sure comments, post, and post_author are cached + update_comment_cache($comments); + $post = get_post($id); + $authordata = get_userdata($post->post_author); + ?> + +<br class="clear" /> + +<table class="widefat" style="margin-top: .5em"> +<thead> + <tr> + <th scope="col"><?php _e('Comment') ?></th> + <th scope="col"><?php _e('Date') ?></th> + <th scope="col"><?php _e('Actions') ?></th> + </tr> +</thead> +<tbody id="the-comment-list" class="list:comment"> +<?php + foreach ($comments as $comment) + _wp_comment_row( $comment->comment_ID, 'detail', false, false ); +?> +</tbody> +</table> + +<?php + +endif; // comments +endif; // posts; + +?> </div> diff --git a/wp-admin/edit-post-rows.php b/wp-admin/edit-post-rows.php index c5e3a58..582db31 100644 --- a/wp-admin/edit-post-rows.php +++ b/wp-admin/edit-post-rows.php @@ -3,23 +3,34 @@ <thead> <tr> -<?php foreach($posts_columns as $column_display_name) { ?> - <th scope="col"><?php echo $column_display_name; ?></th> +<?php $posts_columns = wp_manage_posts_columns(); ?> +<?php foreach($posts_columns as $post_column_key => $column_display_name) { + if ( 'cb' === $post_column_key ) + $class = ' class="check-column"'; + elseif ( 'comments' === $post_column_key ) + $class = ' class="num"'; + else + $class = ''; +?> + <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th> <?php } ?> </tr> </thead> - <tbody id="the-list"> + <tbody> <?php if ( have_posts() ) { $bgcolor = ''; add_filter('the_title','wp_specialchars'); while (have_posts()) : the_post(); -$class = ('alternate' == $class) ? '' : 'alternate'; +$class = 'alternate' == $class ? '' : 'alternate'; global $current_user; $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); +$title = get_the_title(); +if ( empty($title) ) + $title = __('(no title)'); ?> - <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>'> + <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top"> <?php @@ -27,53 +38,122 @@ foreach($posts_columns as $column_name=>$column_display_name) { switch($column_name) { - case 'id': + case 'cb': ?> - <th scope="row" style="text-align: center"><?php echo $id ?></th> + <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /><?php } ?></th> <?php break; case 'modified': - ?> - <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Never'); else the_modified_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td> - <?php - break; case 'date': + if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + if ( 'modified' == $column_name ) { + $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); + $m_time = $post->post_modified; + $time = get_post_modified_time('G', true); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $post->post_date; + $time = get_post_time('G', true); + } + if ( ( abs(time() - $time) ) < 86400 ) { + if ( ( 'future' == $post->post_status) ) + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + else + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + } else { + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } ?> - <td><?php if ( '0000-00-00 00:00:00' ==$post->post_date) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td> + <td><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td> <?php break; case 'title': ?> - <td><?php the_title() ?> - <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td> + <td><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="post.php?action=edit&post=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; } ?></strong> + <?php if ( !empty($post->post_password) ) { _e(' — <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' — <strong>Private</strong>'); } ?></td> <?php break; case 'categories': ?> - <td><?php the_category(','); ?></td> + <td><?php + $categories = get_the_category(); + if ( !empty( $categories ) ) { + $out = array(); + foreach ( $categories as $c ) + $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; + echo join( ', ', $out ); + } else { + _e('Uncategorized'); + } + ?></td> + <?php + break; + + case 'tags': + ?> + <td><?php + $tags = get_the_tags(); + if ( !empty( $tags ) ) { + $out = array(); + foreach ( $tags as $c ) + $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; + echo join( ', ', $out ); + } else { + _e('No Tags'); + } + ?></td> <?php break; case 'comments': ?> - <td style="text-align: center"> + <td class="num"><div class="post-com-count-wrapper"> <?php $left = get_pending_comments_num( $post->ID ); $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); if ( $left ) echo '<strong>'; - comments_number("<a href='edit.php?p=$id&c=1' title='$pending_phrase'>" . __('0') . '</a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase'>" . __('1') . '</a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase'>" . __('%') . '</a>'); + comments_number("<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); if ( $left ) echo '</strong>'; ?> - </td> + </div></td> <?php break; case 'author': ?> - <td><?php the_author() ?></td> + <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td> + <?php + break; + + case 'status': + ?> + <td> + <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink"> + <?php + switch ( $post->post_status ) { + case 'publish' : + case 'private' : + _e('Published'); + break; + case 'future' : + _e('Scheduled'); + break; + case 'pending' : + _e('Pending Review'); + break; + case 'draft' : + _e('Unpublished'); + break; + } + ?> + </a> + </td> <?php break; @@ -91,7 +171,7 @@ foreach($posts_columns as $column_name=>$column_display_name) { case 'control_delete': ?> - <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td> + <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td> <?php break; diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php index c3a6665..62a8e2b 100644 --- a/wp-admin/edit-tag-form.php +++ b/wp-admin/edit-tag-form.php @@ -2,14 +2,14 @@ if ( ! empty($tag_ID) ) { $heading = __('Edit Tag'); $submit_text = __('Edit Tag'); - $form = '<form name="edittag" id="edittag" method="post" action="edit-tags.php">'; + $form = '<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">'; $action = 'editedtag'; $nonce_action = 'update-tag_' . $tag_ID; do_action('edit_tag_form_pre', $tag); } else { $heading = __('Add Tag'); $submit_text = __('Add Tag'); - $form = '<form name="addtag" id="addtag" method="post" action="edit-tags.php" class="add:the-list:">'; + $form = '<form name="addtag" id="addtag" method="post" action="edit-tags.php" class="add:the-list: validate">'; $action = 'addtag'; $nonce_action = 'add-tag'; do_action('add_tag_form_pre', $tag); @@ -22,7 +22,7 @@ if ( ! empty($tag_ID) ) { <?php echo $form ?> <input type="hidden" name="action" value="<?php echo $action ?>" /> <input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" /> -<?php wp_nonce_field($nonce_action); ?> +<?php wp_original_referer_field(true, 'previous'); wp_nonce_field($nonce_action); ?> <table class="form-table"> <tr class="form-field form-required"> <th scope="row" valign="top"><label for="name"><?php _e('Tag name') ?></label></th> diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index fe6b89f..b50269b 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -52,7 +52,14 @@ case 'bulk-delete': wp_delete_term( $tag_ID, 'post_tag'); } - wp_redirect('edit-tags.php?message=6'); + $location = 'edit-tags.php'; + if ( $referer = wp_get_referer() ) { + if ( false !== strpos($referer, 'edit-tags.php') ) + $location = $referer; + } + + $location = add_query_arg('message', 6, $location); + wp_redirect($location); exit; break; @@ -75,11 +82,19 @@ case 'editedtag': wp_die(__('Cheatin’ uh?')); $ret = wp_update_term($tag_ID, 'post_tag', $_POST); - if( $ret && !is_wp_error( $ret ) ) { - wp_redirect('edit-tags.php?message=3'); - } else { - wp_redirect('edit-tags.php?message=5'); + + $location = 'edit-tags.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'edit-tags.php') ) + $location = $referer; } + + if ( $ret && !is_wp_error( $ret ) ) + $location = add_query_arg('message', 3, $location); + else + $location = add_query_arg('message', 5, $location); + + wp_redirect($location); exit; break; @@ -122,7 +137,7 @@ endif; ?> <input type="submit" value="<?php _e( 'Search Tags' ); ?>" class="button" /> </p> -<br style="clear:both;" /> +<br class="clear" /> <div class="tablenav"> @@ -144,22 +159,22 @@ if ( $page_links ) echo "<div class='tablenav-pages'>$page_links</div>"; ?> -<div style="float: left"> +<div class="alignleft"> <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> <?php wp_nonce_field('bulk-tags'); ?> </div> -<br style="clear:both;" /> +<br class="clear" /> </div> -<br style="clear:both;" /> +<br class="clear" /> <table class="widefat"> <thead> <tr> - <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> + <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> <th scope="col"><?php _e('Name') ?></th> - <th scope="col" style="width: 90px"><?php _e('Posts') ?></th> + <th scope="col" class="num" style="width: 90px"><?php _e('Posts') ?></th> </tr> </thead> <tbody id="the-list" class="list:tag"> @@ -173,16 +188,15 @@ $count = tag_rows( $pagenum, $tagsperpage, $searchterms ); </table> </form> -<br style="clear:both;" /> - <div class="tablenav"> <?php if ( $page_links ) echo "<div class='tablenav-pages'>$page_links</div>"; ?> -<br style="clear:both;" /> +<br class="clear" /> </div> +<br class="clear" /> </div> diff --git a/wp-admin/edit.php b/wp-admin/edit.php index ba4cc04..0da6d50 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -1,76 +1,61 @@ <?php require_once('admin.php'); -$title = __('Posts'); -$parent_file = 'edit.php'; -wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' ); -require_once('admin-header.php'); +// Handle bulk deletes +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { + check_admin_referer('bulk-posts'); + foreach( (array) $_GET['delete'] as $post_id_del ) { + $post_del = & get_post($post_id_del); + + if ( !current_user_can('delete_post', $post_id_del) ) + wp_die( __('You are not allowed to delete this post.') ); + + if ( $post_del->post_type == 'attachment' ) { + if ( ! wp_delete_attachment($post_id_del) ) + wp_die( __('Error in deleting...') ); + } else { + if ( !wp_delete_post($post_id_del) ) + wp_die( __('Error in deleting...') ); + } + } -$_GET['m'] = (int) $_GET['m']; -$_GET['cat'] = (int) $_GET['cat']; -$post_stati = array( // array( adj, noun ) - 'publish' => array(__('Published'), __('Published posts')), - 'future' => array(__('Scheduled'), __('Scheduled posts')), - 'pending' => array(__('Pending Review'), __('Pending posts')), - 'draft' => array(__('Draft'), _c('Drafts|manage posts header')), - 'private' => array(__('Private'), __('Private posts')) - ); - -$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'"); - -$post_status_q = ''; -$post_status_label = __('Posts'); -if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { - $post_status_label = $post_stati[$_GET['post_status']][1]; - $post_status_q = '&post_status=' . $_GET['post_status']; + $sendback = wp_get_referer(); + if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php'; + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; + $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); + + wp_redirect($sendback); + exit(); +} elseif ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; } -?> -<div class="wrap"> +$title = __('Posts'); +$parent_file = 'edit.php'; +wp_enqueue_script('admin-forms'); -<?php +list($post_stati, $avail_post_stati) = wp_edit_posts_query(); -if ( 'pending' === $_GET['post_status'] ) { - $order = 'ASC'; - $orderby = 'modified'; -} elseif ( 'draft' === $_GET['post_status'] ) { - $order = 'DESC'; - $orderby = 'modified'; -} else { - $order = 'DESC'; - $orderby = 'date'; -} +if ( 1 == count($posts) && is_singular() ) + wp_enqueue_script( 'admin-comments' ); +require_once('admin-header.php'); -wp("what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby"); - -// define the columns to display, the syntax is 'internal name' => 'display name' -$posts_columns = array(); -$posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>'; -if ( 'draft' === $_GET['post_status'] ) - $posts_columns['modified'] = __('Modified'); -elseif ( 'pending' === $_GET['post_status'] ) - $posts_columns['modified'] = __('Submitted'); -else - $posts_columns['date'] = __('When'); -$posts_columns['title'] = __('Title'); -$posts_columns['categories'] = __('Categories'); -if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) - $posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>'; -$posts_columns['author'] = __('Author'); - -$posts_columns = apply_filters('manage_posts_columns', $posts_columns); - -// you can not edit these at the moment -$posts_columns['control_view'] = ''; -$posts_columns['control_edit'] = ''; -$posts_columns['control_delete'] = ''; +if ( !isset( $_GET['paged'] ) ) + $_GET['paged'] = 1; ?> +<div class="wrap"> + +<form id="posts-filter" action="" method="get"> <h2><?php if ( is_single() ) { printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title)); } else { + $post_status_label = _c('Manage Posts|manage posts header'); + if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) + $post_status_label = $post_stati[$_GET['post_status']][1]; if ( $post_listing_pageable && !is_archive() && !is_search() ) $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label); else @@ -88,36 +73,72 @@ if ( is_single() ) { } $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : ''; $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; + $h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : ''; $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; - printf( _c( '%1$s%2$s%3$s%4$s%5$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_month ); + printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month ); } ?></h2> -<form name="searchform" id="searchform" action="" method="get"> - <fieldset><legend><?php _e('Search terms…'); ?></legend> - <input type="text" name="s" id="s" value="<?php the_search_query(); ?>" size="17" /> - </fieldset> - - <fieldset><legend><?php _e('Status…'); ?></legend> - <select name='post_status'> - <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option> -<?php foreach ( $post_stati as $status => $label ) : if ( !in_array($status, $avail_post_stati) ) continue; ?> - <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option> -<?php endforeach; ?> - </select> - </fieldset> - +<ul class="subsubsub"> <?php -$editable_ids = get_editable_user_ids( $user_ID ); -if ( $editable_ids && count( $editable_ids ) > 1 ) : +$status_links = array(); +$num_posts = wp_count_posts( 'post', 'readable' ); +$class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; +$status_links[] = "<li><a href='edit.php' $class>" . __('All Posts') . '</a>'; +foreach ( $post_stati as $status => $label ) { + $class = ''; + + if ( !in_array( $status, $avail_post_stati ) ) + continue; + + if ( empty( $num_posts->$status ) ) + continue; + if ( $status == $_GET['post_status'] ) + $class = ' class="current"'; + + $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . + sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; +} +echo implode( ' |</li>', $status_links ) . '</li>'; +unset( $status_links ); ?> - <fieldset><legend><?php _e('Author…'); ?></legend> - <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?> - </fieldset> +</ul> +<?php if ( isset($_GET['post_status'] ) ) : ?> +<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" /> <?php endif; +if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> +<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit post'); ?></a></p></div> +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); +endif; +?> + +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" /> + <input type="submit" value="<?php _e( 'Search Posts' ); ?>" class="button" /> +</p> + +<div class="tablenav"> + +<?php +$page_links = paginate_links( array( + 'base' => add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'total' => $wp_query->max_num_pages, + 'current' => $_GET['paged'] +)); + +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; +?> + +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php wp_nonce_field('bulk-posts'); ?> +<?php +if ( !is_singular() ) { $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC"; $arc_result = $wpdb->get_results( $arc_query ); @@ -125,99 +146,94 @@ $arc_result = $wpdb->get_results( $arc_query ); $month_count = count($arc_result); if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> +<select name='m'> +<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> +<?php +foreach ($arc_result as $arc_row) { + if ( $arc_row->yyear == 0 ) + continue; + $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); - <fieldset><legend><?php _e('Month…') ?></legend> - <select name='m'> - <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Any'); ?></option> - <?php - foreach ($arc_result as $arc_row) { - if ( $arc_row->yyear == 0 ) - continue; - $arc_row->mmonth = zeroise($arc_row->mmonth, 2); - - if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) - $default = ' selected="selected"'; - else - $default = ''; - - echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>"; - echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; - echo "</option>\n"; - } - ?> - </select> - </fieldset> + if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) + $default = ' selected="selected"'; + else + $default = ''; + echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>"; + echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; + echo "</option>\n"; +} +?> +</select> <?php } ?> - <fieldset><legend><?php _e('Category…') ?></legend> - <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?> - </fieldset> - <input type="submit" id="post-query-submit" value="<?php _e('Filter »'); ?>" class="button" /> -</form> - +<?php wp_dropdown_categories('show_option_all='.__('View all categories').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?> <?php do_action('restrict_manage_posts'); ?> +<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" /> + +<?php } ?> +</div> + +<br class="clear" /> +</div> -<br style="clear:both;" /> +<br class="clear" /> <?php include( 'edit-post-rows.php' ); ?> +</form> + <div id="ajax-response"></div> -<div class="navigation"> -<div class="alignleft"><?php next_posts_link(__('« Previous Entries')) ?></div> -<div class="alignright"><?php previous_posts_link(__('Next Entries »')) ?></div> +<div class="tablenav"> + +<?php +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; +?> + +<br class="clear" /> </div> +<br class="clear" /> + <?php -if ( 1 == count($posts) ) { +if ( 1 == count($posts) && is_singular() ) : $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); - if ($comments) { + if ( $comments ) : + // Make sure comments, post, and post_author are cached update_comment_cache($comments); + $post = get_post($id); + $authordata = get_userdata($post->post_author); ?> -<h3 id="comments"><?php _e('Comments') ?></h3> -<ol id="the-comment-list" class="commentlist"> -<?php -$i = 0; -foreach ($comments as $comment) { - ++$i; $class = ''; - $post = get_post($comment->comment_post_ID); - $authordata = get_userdata($post->post_author); - $comment_status = wp_get_comment_status($comment->comment_ID); - if ('unapproved' == $comment_status) - $class .= ' unapproved'; - if ($i % 2) - $class .= ' alternate'; - echo "<li id='comment-$comment->comment_ID' class='$class'>"; +<br class="clear" /> + +<table class="widefat" style="margin-top: .5em"> +<thead> + <tr> + <th scope="col"><?php _e('Comment') ?></th> + <th scope="col"><?php _e('Date') ?></th> + <th scope="col"><?php _e('Actions') ?></th> + </tr> +</thead> +<tbody id="the-comment-list" class="list:comment"> +<?php + foreach ($comments as $comment) + _wp_comment_row( $comment->comment_ID, 'detail', false, false ); ?> -<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="edit-comments.php?s=<?php comment_author_IP() ?>&mode=edit"><?php comment_author_IP() ?></a></p> +</tbody> +</table> -<?php comment_text() ?> - -<p><?php comment_date(__('M j, g:i A')); ?> — [ <?php -if ( current_user_can('edit_post', $comment->comment_post_ID) ) { - echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; - echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; - if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { - echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; - echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; - } - echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; -} -?> ] -</p> - </li> -<?php //end of the loop, don't delete - } // end foreach - echo '</ol>'; - }//end if comments - ?> -<?php } ?> +endif; // comments +endif; // posts; + +?> + </div> <?php include('admin-footer.php'); ?> diff --git a/wp-admin/export.php b/wp-admin/export.php index 69741bc..e36b8bb 100644 --- a/wp-admin/export.php +++ b/wp-admin/export.php @@ -1,29 +1,31 @@ <?php require_once ('admin.php'); +require_once('includes/export.php'); $title = __('Export'); $parent_file = 'edit.php'; -if ( isset( $_GET['download'] ) ) - export_wp(); +if ( isset( $_GET['download'] ) ) { + export_wp( $_GET['author'] ); + die(); +} require_once ('admin-header.php'); ?> <div class="wrap"> <h2><?php _e('Export'); ?></h2> -<div class="narrow"> <p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p> -<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p> +<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p> <p><?php _e('Once you’ve saved the download file, you can use the Import function on another WordPress blog to import this blog.'); ?></p> <form action="" method="get"> -<h3><?php _e('Optional options'); ?></h3> +<h3><?php _e('Options'); ?></h3> -<table> +<table class="form-table"> <tr> -<th><?php _e('Restrict Author:'); ?></th> +<th><?php _e('Restrict Author'); ?></th> <td> <select name="author"> -<option value="all" selected="selected"><?php _e('All'); ?></option> +<option value="all" selected="selected"><?php _e('All Authors'); ?></option> <?php $authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" ); foreach ( $authors as $id ) { @@ -35,7 +37,7 @@ foreach ( $authors as $id ) { </td> </tr> </table> -<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> »" /> +<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?>" /> <input type="hidden" name="download" value="true" /> </p> </form> @@ -45,229 +47,6 @@ foreach ( $authors as $id ) { <?php -function export_wp() { -global $wpdb, $post_ids, $post; - -do_action('export_wp'); - -$filename = 'wordpress.' . date('Y-m-d') . '.xml'; - -header('Content-Description: File Transfer'); -header("Content-Disposition: attachment; filename=$filename"); -header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); - -$where = ''; -if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) { - $author_id = (int) $_GET['author']; - $where = " WHERE post_author = '$author_id' "; -} - -// grab a snapshot of post IDs, just in case it changes during the export -$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); - -$categories = (array) get_categories('get=all'); -$tags = (array) get_tags('get=all'); - -function wxr_missing_parents($categories) { - if ( !is_array($categories) || empty($categories) ) - return array(); - - foreach ( $categories as $category ) - $parents[$category->term_id] = $category->parent; - - $parents = array_unique(array_diff($parents, array_keys($parents))); - - if ( $zero = array_search('0', $parents) ) - unset($parents[$zero]); - - return $parents; -} - -while ( $parents = wxr_missing_parents($categories) ) { - $found_parents = get_categories("include=" . join(', ', $parents)); - if ( is_array($found_parents) && count($found_parents) ) - $categories = array_merge($categories, $found_parents); - else - break; -} - -// Put them in order to be inserted with no child going before its parent -$pass = 0; -$passes = 1000 + count($categories); -while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { - if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { - $cats[$cat->term_id] = $cat; - } else { - $categories[] = $cat; - } -} -unset($categories); - -function wxr_cdata($str) { - if ( seems_utf8($str) == false ) - $str = utf8_encode($str); - - // $str = ent2ncr(wp_specialchars($str)); - - $str = "<![CDATA[$str" . ( ( substr($str, -1) == ']' ) ? ' ' : '') . "]]>"; - - return $str; -} - -function wxr_cat_name($c) { - if ( empty($c->name) ) - return; - - echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>'; -} - -function wxr_category_description($c) { - if ( empty($c->description) ) - return; - - echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>'; -} - -function wxr_tag_name($t) { - if ( empty($t->name) ) - return; - - echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>'; -} - -function wxr_tag_description($t) { - if ( empty($t->description) ) - return; - - echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>'; -} - -function wxr_post_taxonomy() { - $categories = get_the_category(); - $tags = get_the_tags(); - $cat_names = array(); - $tag_names = array(); - $the_list = ''; - $filter = 'rss'; - - if ( !empty($categories) ) foreach ( (array) $categories as $category ) { - $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); - $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n"; - } - - if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { - $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); - $the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[$tag_name]]></category>\n"; - } - - echo $the_list; -} - -echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n"; - -?> -<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. --> -<!-- It contains information about your blog's posts, comments, and categories. --> -<!-- You may use this file to transfer that content from one site to another. --> -<!-- This file is not intended to serve as a complete backup of your blog. --> - -<!-- To import this information into a WordPress blog follow these steps. --> -<!-- 1. Log into that blog as an administrator. --> -<!-- 2. Go to Manage: Import in the blog's admin panels. --> -<!-- 3. Choose "WordPress" from the list. --> -<!-- 4. Upload this file using the form provided on that page. --> -<!-- 5. You will first be asked to map the authors in this export file to users --> -<!-- on the blog. For each author, you may choose to map to an --> -<!-- existing user on the blog or to create a new user --> -<!-- 6. WordPress will then import each of the posts, comments, and categories --> -<!-- contained in this file into your blog --> - -<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:i'); ?>"--> -<rss version="2.0" - xmlns:content="http://purl.org/rss/1.0/modules/content/" - xmlns:wfw="http://wellformedweb.org/CommentAPI/" - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:wp="http://wordpress.org/export/1.0/" -> - -<channel> - <title><?php bloginfo_rss('name'); ?></title> - <link><?php bloginfo_rss('url') ?></link> - <description><?php bloginfo_rss("description") ?></description> - <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate> - <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator> - <language><?php echo get_option('rss_language'); ?></language> -<?php if ( $cats ) : foreach ( $cats as $c ) : ?> - <wp:category><wp:category_nicename><?php echo $c->slug; ?></wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->name : ''; ?></wp:category_parent><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category> -<?php endforeach; endif; ?> -<?php if ( $tags ) : foreach ( $tags as $t ) : ?> - <wp:tag><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name($t); ?><?php wxr_tag_description($t); ?></wp:tag> -<?php endforeach; endif; ?> - <?php do_action('rss2_head'); ?> - <?php if ($post_ids) { - global $wp_query; - $wp_query->in_the_loop = true; // Fake being in the loop. - // fetch 20 posts at a time rather than loading the entire table into memory - while ( $next_posts = array_splice($post_ids, 0, 20) ) { - $where = "WHERE ID IN (".join(',', $next_posts).")"; - $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); - foreach ($posts as $post) { - setup_postdata($post); ?> -<item> -<title><?php the_title_rss() ?></title> -<link><?php the_permalink_rss() ?></link> -<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> -<dc:creator><?php the_author() ?></dc:creator> -<?php wxr_post_taxonomy() ?> - -<guid isPermaLink="false"><?php the_guid(); ?></guid> -<description></description> -<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded> -<wp:post_id><?php echo $post->ID; ?></wp:post_id> -<wp:post_date><?php echo $post->post_date; ?></wp:post_date> -<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt> -<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status> -<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status> -<wp:post_name><?php echo $post->post_name; ?></wp:post_name> -<wp:status><?php echo $post->post_status; ?></wp:status> -<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent> -<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order> -<wp:post_type><?php echo $post->post_type; ?></wp:post_type> -<?php -$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); -if ( $postmeta ) { -?> -<?php foreach( $postmeta as $meta ) { ?> -<wp:postmeta> -<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key> -<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value> -</wp:postmeta> -<?php } ?> -<?php } ?> -<?php -$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); -if ( $comments ) { foreach ( $comments as $c ) { ?> -<wp:comment> -<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id> -<wp:comment_author><?php echo wxr_cdata($c->comment_author); ?></wp:comment_author> -<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email> -<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url> -<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP> -<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date> -<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt> -<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content> -<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved> -<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type> -<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent> -</wp:comment> -<?php } } ?> - </item> -<?php } } } ?> -</channel> -</rss> -<?php - die(); -} include ('admin-footer.php'); ?> diff --git a/wp-admin/images/bubble_bg.gif b/wp-admin/images/bubble_bg.gif Binary files differindex c6f395a..315ab52 100644 --- a/wp-admin/images/bubble_bg.gif +++ b/wp-admin/images/bubble_bg.gif diff --git a/wp-admin/images/comment-stalk-rtl.gif b/wp-admin/images/comment-stalk-rtl.gif Binary files differnew file mode 100644 index 0000000..6b0cb0b --- /dev/null +++ b/wp-admin/images/comment-stalk-rtl.gif diff --git a/wp-admin/images/logo-ghost.png b/wp-admin/images/logo-ghost.png Binary files differindex 46d26cc..ad57ace 100644 --- a/wp-admin/images/logo-ghost.png +++ b/wp-admin/images/logo-ghost.png diff --git a/wp-admin/images/toggle-arrow-rtl.gif b/wp-admin/images/toggle-arrow-rtl.gif Binary files differnew file mode 100644 index 0000000..c96b944 --- /dev/null +++ b/wp-admin/images/toggle-arrow-rtl.gif diff --git a/wp-admin/images/wordpress-logo.png b/wp-admin/images/wordpress-logo.png Binary files differindex 3c852f4..7421f21 100644 --- a/wp-admin/images/wordpress-logo.png +++ b/wp-admin/images/wordpress-logo.png diff --git a/wp-admin/import.php b/wp-admin/import.php index 9637279..c38b6d8 100644 --- a/wp-admin/import.php +++ b/wp-admin/import.php @@ -44,7 +44,7 @@ if (empty ($importers)) { $style = 'class="'.$style.'"';
echo "
<tr $style>
- <td class='import-system'>$action</td>
+ <td class='import-system row-title'>$action</td>
<td class='desc'>{$data[1]}</td>
</tr>";
}
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php index 23e0807..fb15c66 100644 --- a/wp-admin/import/blogger.php +++ b/wp-admin/import/blogger.php @@ -12,7 +12,7 @@ class Blogger_Import { $auth_url = "https://www.google.com/accounts/AuthSubRequest";
$title = __('Import Blogger');
$welcome = __('Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.');
- $prereqs = __('To use this importer, you must have a Google account, an upgraded (New, was Beta) blog, and it must be on blogspot or a custom domain (not FTP).');
+ $prereqs = __('To use this importer, you must have a Google account and an upgraded (New, was Beta) blog hosted on blogspot.com or a custom domain (not FTP).');
$stepone = __('The first thing you need to do is tell Blogger to let WordPress access your account. You will be sent back here after providing authorization.');
$auth = __('Authorize');
@@ -20,7 +20,7 @@ class Blogger_Import { <div class='wrap'><h2>$title</h2><p>$welcome</p><p>$prereqs</p><p>$stepone</p>
<form action='$auth_url' method='get'>
<p class='submit' style='text-align:left;'>
- <input type='submit' value='$auth' />
+ <input type='submit' class='button' value='$auth' />
<input type='hidden' name='scope' value='http://www.blogger.com/feeds/' />
<input type='hidden' name='session' value='1' />
<input type='hidden' name='secure' value='0' />
@@ -178,7 +178,7 @@ class Blogger_Import { $init .= "blogs[$i]=new blog($i,'$blogtitle','{$blog['mode']}'," . $this->get_js_status($i) . ');';
$pstat = "<div class='ind' id='pind$i'> </div><div id='pstat$i' class='stat'>$pdone/{$blog['total_posts']}</div>";
$cstat = "<div class='ind' id='cind$i'> </div><div id='cstat$i' class='stat'>$cdone/{$blog['total_comments']}</div>";
- $rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n";
+ $rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' class='button' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n";
}
echo "<div class='wrap'><h2>$title</h2><noscript>$noscript</noscript><table cellpadding='5px'><thead><td>$name</td><td>$url</td><td>$posts</td><td>$comments</td><td>$action</td></thead>\n$rows</table></form></div>";
@@ -381,7 +381,7 @@ class Blogger_Import { $AtomParser = new AtomParser();
$AtomParser->parse( $entry );
$result = $this->import_post($AtomParser->entry);
- if ( is_wp_error( $result ) )
+ if ( is_wp_error( $result ) )
return $result;
unset($AtomParser);
}
@@ -520,7 +520,7 @@ class Blogger_Import { $post = compact('post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($post);
- if ( is_wp_error( $post_id ) )
+ if ( is_wp_error( $post_id ) )
return $post_id;
wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id );
@@ -613,12 +613,12 @@ class Blogger_Import { $blogtitle = "{$blog['title']} ({$blog['host']})";
$mapthis = __('Blogger username');
$tothis = __('WordPress login');
- $submit = js_escape( __('Save Changes »') );
+ $submit = js_escape( __('Save Changes') );
foreach ( $blog['authors'] as $i => $author )
$rows .= "<tr><td><label for='authors[$i]'>{$author[0]}</label></td><td><select name='authors[$i]' id='authors[$i]'>" . $this->get_user_options($author[1]) . "</select></td></tr>";
- return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='authorsubmit' value='$submit' /></td></tr></table></form></div>";
+ return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='button authorsubmit' value='$submit' /></td></tr></table></form></div>";
}
function get_user_options($current) {
@@ -788,7 +788,7 @@ class Blogger_Import { $restart = __('Restart');
$message = __('We have saved some information about your Blogger account in your WordPress database. Clearing this information will allow you to start over. Restarting will not affect any posts you have already imported. If you attempt to re-import a blog, duplicate posts and comments will be skipped.');
$submit = __('Clear account information');
- echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' value='$submit' name='restart' /></p></form></div>";
+ echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' class='button' value='$submit' name='restart' /></p></form></div>";
}
}
@@ -821,9 +821,6 @@ thead td { font-weight: bold; } position: relative;
text-align: center;
}
-.submit {
- text-align: center !important;
-}
</style>
<?php
}
@@ -840,7 +837,7 @@ thead td { font-weight: bold; } $blogger_import = new Blogger_Import();
-register_importer('blogger', __('Blogger'), __('Import posts, comments, and users from a Blogger blog'), array ($blogger_import, 'start'));
+register_importer('blogger', __('Blogger'), __('Import posts, comments, and users from a Blogger blog.'), array ($blogger_import, 'start'));
class AtomEntry {
var $links = array();
diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php index 0083230..0054db2 100644 --- a/wp-admin/import/blogware.php +++ b/wp-admin/import/blogware.php @@ -86,9 +86,9 @@ class BW_Import { echo '<li>';
if ($post_id = post_exists($post_title, $post_content, $post_date)) {
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title));
} else {
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ printf(__('Importing post <em>%s</em>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
if ( is_wp_error( $post_id ) ) {
@@ -141,7 +141,7 @@ class BW_Import { }
if ( $num_comments ) {
echo ' ';
- printf(__('(%s comments)'), $num_comments);
+ printf( __ngettext('%s comment', '%s comments', $num_comments), $num_comments );
}
echo '</li>';
flush();
@@ -162,7 +162,7 @@ class BW_Import { if ( is_wp_error( $result ) )
return $result;
wp_import_cleanup($file['id']);
-
+ do_action('import_done', 'blogware');
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
@@ -197,5 +197,5 @@ class BW_Import { $blogware_import = new BW_Import();
-register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
+register_importer('blogware', __('Blogware'), __('Import posts from Blogware.'), array ($blogware_import, 'dispatch'));
?>
diff --git a/wp-admin/import/btt.php b/wp-admin/import/btt.php index 76a02c3..4bd884c 100644 --- a/wp-admin/import/btt.php +++ b/wp-admin/import/btt.php @@ -14,13 +14,13 @@ class BunnyTags_Import { function greet() { echo '<div class="narrow">'; - echo '<p>'.__('Howdy! This imports tags from an existing Bunny’s Technorati Tags installation into this blog using the new WordPress native tagging structure.').'</p>'; + echo '<p>'.__('Howdy! This imports tags from Bunny’s Technorati Tags into WordPress tags.').'</p>'; echo '<p>'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'</p>'; echo '<p><strong>'.__('All existing Bunny’s Technorati Tags will be removed after import.').'</strong></p>'; echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>'; echo '<form action="admin.php?import=btt&step=1" method="post">'; wp_nonce_field('import-btt'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -29,7 +29,7 @@ class BunnyTags_Import { if ( empty($_GET['step']) ) $step = 0; else - $step = abs(intval($_GET['step'])); + $step = absint($_GET['step']); // load the header $this->header(); @@ -61,14 +61,14 @@ class BunnyTags_Import { echo '<div class="narrow">'; echo '<p><h3>'.__('Reading Bunny’s Technorati Tags…').'</h3></p>'; - // import Bunny's Keywords tags + // import Bunny's Keywords tags $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'"); if ( !is_array($metakeys)) { echo '<p>' . __('No Tags Found!') . '</p>'; return false; } else { $count = count($metakeys); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count ) . '<br /></p>'; echo '<ul>'; foreach ( $metakeys as $post_meta ) { if ( $post_meta->meta_value != '' ) { @@ -90,7 +90,7 @@ class BunnyTags_Import { echo '<form action="admin.php?import=btt&step='.($precheck? 2:3).'" method="post">'; wp_nonce_field('import-btt'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -110,6 +110,6 @@ class BunnyTags_Import { $btt_import = new BunnyTags_Import(); // add it to the import page! -register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into the new native tagging structure.'), array($btt_import, 'dispatch')); +register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into WordPress tags.'), array($btt_import, 'dispatch')); ?> diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php index 1bf0486..16df934 100644 --- a/wp-admin/import/dotclear.php +++ b/wp-admin/import/dotclear.php @@ -128,7 +128,7 @@ class Dotclear_Import { echo '<form action="admin.php?import=dotclear&step=1" method="post">'; wp_nonce_field('import-dotclear'); $this->db_form(); - echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories')).'" /></p>'; echo '</form></div>'; } @@ -225,7 +225,7 @@ class Dotclear_Import { // Store category translation for future use add_option('dccat2wpcat',$dccat2wpcat); - echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>'; + echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>'; return true; } echo __('No Categories to Import!'); @@ -526,7 +526,7 @@ class Dotclear_Import { } add_option('dclinks2wplinks',$dclinks2wplinks); echo '<p>'; - printf(__('Done! <strong>%s</strong> links or link categories imported'), $count); + printf(__ngettext('Done! <strong>%s</strong> link or link category imported.', 'Done! <strong>%s</strong> links or link categories imported.', $count), $count); echo '<br /><br /></p>'; return true; } @@ -615,6 +615,7 @@ class Dotclear_Import { delete_option('dcname'); delete_option('dchost'); delete_option('dccharset'); + do_action('import_done', 'dotclear'); $this->tips(); } @@ -639,7 +640,7 @@ class Dotclear_Import { function db_form() { - echo '<table class="editform">'; + echo '<table class="form-table">'; printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('DotClear Database User:')); printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:')); printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('DotClear Database Name:')); @@ -741,5 +742,5 @@ class Dotclear_Import { } $dc_import = new Dotclear_Import(); -register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog'), array ($dc_import, 'dispatch')); +register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch')); ?> diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php index 6e92235..92abc48 100644 --- a/wp-admin/import/greymatter.php +++ b/wp-admin/import/greymatter.php @@ -36,7 +36,7 @@ class GM_Import { <input type="hidden" name="step" value="1" /> <?php wp_nonce_field('import-greymatter'); ?> <h3><?php _e('Second step: GreyMatter details:') ?></h3> -<p><table cellpadding="0"> +<table class="form-table"> <tr> <td><?php _e('Path to GM files:') ?></td> <td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td> @@ -46,17 +46,14 @@ class GM_Import { <td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td> </tr> <tr> -<td colspan="2"><br /><?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td> -</tr> -<tr> <td><?php _e("Last entry's number:") ?></td> -<td><input type="text" name="lastentry" value="00000001" /></td> +<td><input type="text" name="lastentry" value="00000001" /><br /> + <?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td> </tr> </table> </p> -<p><?php _e("When you're ready, click OK to start importing: ") ?><input type="submit" name="submit" value="<?php _e('OK') ?>" class="search" /></p> +<p><input type="submit" name="submit" value="<?php _e('Start Importing') ?>" class="button" /></p> </form> -<p> </p> <?php $this->footer(); } @@ -272,17 +269,18 @@ class GM_Import { } if ($numAddedComments > 0) { echo ': '; - printf(__('imported %d comment(s)'), $numAddedComments); + printf( __ngettext('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments); } $preExisting = $numComments - numAddedComments; if ($preExisting > 0) { echo ' '; - printf(__('ignored %d pre-existing comments'), $preExisting); + printf( __ngettext( 'ignored %s pre-existing comment', 'ignored %s pre-existing comments', $preExisting ) , $preExisting); } } echo '... <strong>'.__('Done').'</strong></li>'; } } + do_action('import_done', 'greymatter'); ?> </ul><strong><?php _e('Done') ?></strong></li></ul> <p> </p> @@ -318,5 +316,5 @@ class GM_Import { $gm_import = new GM_Import(); -register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog'), array ($gm_import, 'dispatch')); +register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog.'), array ($gm_import, 'dispatch')); ?> diff --git a/wp-admin/import/jkw.php b/wp-admin/import/jkw.php index 9f7b48e..1bb0ad6 100644 --- a/wp-admin/import/jkw.php +++ b/wp-admin/import/jkw.php @@ -14,17 +14,17 @@ class JeromesKeyword_Import { function greet() { echo '<div class="narrow">'; - echo '<p>'.__('Howdy! This imports tags from an existing Jerome’s Keywords installation into this blog using the new WordPress native tagging structure.').'</p>'; + echo '<p>'.__('Howdy! This imports tags from Jerome’s Keywords into WordPress tags.').'</p>'; echo '<p>'.__('This is suitable for Jerome’s Keywords version 1.x and 2.0a.').'</p>'; echo '<p><strong>'.__('All existing Jerome’s Keywords will be removed after import.').'</strong></p>'; echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>'; echo '<form action="admin.php?import=jkw&step=1" method="post">'; wp_nonce_field('import-jkw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Version 1.x »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Version 1.x').'" /></p>'; echo '</form>'; echo '<form action="admin.php?import=jkw&step=3" method="post">'; wp_nonce_field('import-jkw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Version 2.0a »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Version 2.0a').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -33,7 +33,7 @@ class JeromesKeyword_Import { if ( empty($_GET['step']) ) $step = 0; else - $step = abs(intval($_GET['step'])); + $step = absint($_GET['step']); // load the header $this->header(); @@ -77,14 +77,14 @@ class JeromesKeyword_Import { echo '<div class="narrow">'; echo '<p><h3>'.__('Reading Jerome’s Keywords Tags…').'</h3></p>'; - // import Jerome's Keywords tags + // import Jerome's Keywords tags $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'"); if ( !is_array($metakeys)) { echo '<p>' . __('No Tags Found!') . '</p>'; return false; } else { $count = count($metakeys); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count ) . '<br /></p>'; echo '<ul>'; foreach ( $metakeys as $post_meta ) { if ( $post_meta->meta_value != '' ) { @@ -106,7 +106,7 @@ class JeromesKeyword_Import { echo '<form action="admin.php?import=jkw&step='.($precheck? 2:6).'" method="post">'; wp_nonce_field('import-jkw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -117,7 +117,7 @@ class JeromesKeyword_Import { echo '<div class="narrow">'; echo '<p><h3>'.__('Reading Jerome’s Keywords Tags…').'</h3></p>'; - // import Jerome's Keywords tags + // import Jerome's Keywords tags $tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1); $metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM $tablename"); if ( !is_array($metakeys) ) { @@ -125,7 +125,7 @@ class JeromesKeyword_Import { return false; } else { $count = count($metakeys); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag were read.', 'Done! <strong>%s</strong> tags were read.', $count), $count ) . '<br /></p>'; echo '<ul>'; foreach ( $metakeys as $post_meta ) { $keyword = addslashes(trim($post_meta->tag_name)); @@ -139,7 +139,7 @@ class JeromesKeyword_Import { } echo '<form action="admin.php?import=jkw&step='.($precheck? 4:5).'" method="post">'; wp_nonce_field('import-jkw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -173,6 +173,6 @@ class JeromesKeyword_Import { $jkw_import = new JeromesKeyword_Import(); // add it to the import page! -register_importer('jkw', 'Jerome’s Keywords', __('Import Jerome’s Keywords into the new native tagging structure.'), array($jkw_import, 'dispatch')); +register_importer('jkw', 'Jerome’s Keywords', __('Import Jerome’s Keywords into WordPress tags.'), array($jkw_import, 'dispatch')); ?> diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php index 81f0365..bd8394e 100644 --- a/wp-admin/import/livejournal.php +++ b/wp-admin/import/livejournal.php @@ -66,9 +66,9 @@ class LJ_Import { echo '<li>'; if ($post_id = post_exists($post_title, $post_content, $post_date)) { - printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); + printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title)); } else { - printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); + printf(__('Importing post <em>%s</em>...'), stripslashes($post_title)); $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); $post_id = wp_insert_post($postdata); if ( is_wp_error( $post_id ) ) @@ -119,7 +119,7 @@ class LJ_Import { } if ( $num_comments ) { echo ' '; - printf(__('(%s comments)'), $num_comments); + printf(__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); } echo '</li>'; } @@ -138,6 +138,7 @@ class LJ_Import { if ( is_wp_error( $result ) ) return $result; wp_import_cleanup($file['id']); + do_action('import_done', 'livejournal'); echo '<h3>'; printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')); @@ -174,5 +175,5 @@ class LJ_Import { $livejournal_import = new LJ_Import(); -register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file'), array ($livejournal_import, 'dispatch')); +register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file.'), array ($livejournal_import, 'dispatch')); ?> diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php index fc59794..6b945b2 100644 --- a/wp-admin/import/mt.php +++ b/wp-admin/import/mt.php @@ -23,8 +23,19 @@ class MT_Import { ?> <div class="narrow"> <p><?php _e('Howdy! We’re about to begin importing all of your Movable Type or Typepad entries into WordPress. To begin, either choose a file to upload and click "Upload file and import," or use FTP to upload your MT export file as <code>mt-export.txt</code> in your <code>/wp-content/</code> directory and then click "Import mt-export.txt"'); ?></p> + <?php wp_import_upload_form( add_query_arg('step', 1) ); ?> - <p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if—for whatever reason—it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p> +<form method="post" action="<?php echo add_query_arg('step', 1); ?>" class="import-upload-form"> + +<?php wp_nonce_field('import-upload'); ?> +<p> + <input type="hidden" name="upload_type" value="ftp" /> +<?php _e('Or use <code>mt-export.txt</code> in your <code>/wp-content/</code> directory'); ?></p> +<p class="submit"> +<input type="submit" value="<?php echo attribute_escape(__('Import mt-export.txt')); ?>" /> +</p> +</form> +<p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if—for whatever reason—it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p> </div> <?php $this->footer(); @@ -126,8 +137,8 @@ class MT_Import { <div class="wrap"> <h2><?php _e('Assign Authors'); ?></h2> <p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as admin\'s entries.'); ?></p> -<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p> -<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p> +<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <em>italics</em>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p> +<p><?php _e('If a new user is created by WordPress, a password will be randomly generated. Manually change the user\'s details if necessary.'); ?></p> <?php @@ -173,23 +184,30 @@ class MT_Import { if ( $post_id = post_exists($post->post_title, '', $post->post_date) ) { echo '<li>'; - printf(__('Post <i>%s</i> already exists.'), stripslashes($post->post_title)); + printf(__('Post <em>%s</em> already exists.'), stripslashes($post->post_title)); } else { echo '<li>'; - printf(__('Importing post <i>%s</i>...'), stripslashes($post->post_title)); + printf(__('Importing post <em>%s</em>...'), stripslashes($post->post_title)); if ( '' != trim( $post->extended ) ) $post->post_content .= "\n<!--more-->\n$post->extended"; $post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor $post_id = wp_insert_post($post); - if ( is_wp_error( $post_id ) ) + if ( is_wp_error( $post_id ) ) return $post_id; // Add categories. if ( 0 != count($post->categories) ) { wp_create_categories($post->categories, $post_id); } + + // Add tags or keywords + if ( 1 < strlen($post->post_keywords) ) { + // Keywords exist. + printf(__('<br />Adding tags <i>%s</i>...'), stripslashes($post->post_keywords)); + wp_add_post_tags($post_id, $post->post_keywords); + } } $num_comments = 0; @@ -206,7 +224,7 @@ class MT_Import { } if ( $num_comments ) - printf(' '.__('(%s comments)'), $num_comments); + printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); $num_pings = 0; foreach ( $pings as $ping ) { @@ -223,7 +241,7 @@ class MT_Import { } if ( $num_pings ) - printf(' '.__('(%s pings)'), $num_pings); + printf(' '.__ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings); echo "</li>"; //ob_flush();flush(); @@ -262,7 +280,7 @@ class MT_Import { // Finishing a post. $context = ''; $result = $this->save_post($post, $comments, $pings); - if ( is_wp_error( $result ) ) + if ( is_wp_error( $result ) ) return $result; $post = new StdClass; $comment = new StdClass(); @@ -364,6 +382,8 @@ class MT_Import { $post->extended .= $line; } else if ( 'excerpt' == $context ) { $post->post_excerpt .= $line; + } else if ( 'keywords' == $context ) { + $post->post_keywords .= $line; } else if ( 'comment' == $context ) { $comment->comment_content .= $line; } else if ( 'ping' == $context ) { @@ -386,7 +406,7 @@ class MT_Import { $this->file = get_attached_file($this->id); $this->get_authors_from_post(); $result = $this->process_posts(); - if ( is_wp_error( $result ) ) + if ( is_wp_error( $result ) ) return $result; } @@ -420,5 +440,5 @@ class MT_Import { $mt_import = new MT_Import(); -register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog'), array ($mt_import, 'dispatch')); +register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog.'), array ($mt_import, 'dispatch')); ?> diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php index 11fc770..60a4490 100644 --- a/wp-admin/import/rss.php +++ b/wp-admin/import/rss.php @@ -71,7 +71,7 @@ class RSS_Import { $cat_index++; } - preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid); + preg_match('|<guid.*?>(.*?)</guid>|is', $post, $guid); if ($guid) $guid = $wpdb->escape(trim($guid[1])); else @@ -141,6 +141,7 @@ class RSS_Import { if ( is_wp_error( $result ) ) return $result; wp_import_cleanup($file['id']); + do_action('import_done', 'rss'); echo '<h3>'; printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')); @@ -177,5 +178,5 @@ class RSS_Import { $rss_import = new RSS_Import(); -register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch')); +register_importer('rss', __('RSS'), __('Import posts from an RSS feed.'), array ($rss_import, 'dispatch')); ?> diff --git a/wp-admin/import/stp.php b/wp-admin/import/stp.php index 9d5371c..53b339a 100644 --- a/wp-admin/import/stp.php +++ b/wp-admin/import/stp.php @@ -12,13 +12,13 @@ class STP_Import { function greet() { echo '<div class="narrow">'; - echo '<p>'.__('Howdy! This imports tags from an existing Simple Tagging 1.6.2 installation into this blog using the new WordPress native tagging structure.').'</p>'; + echo '<p>'.__('Howdy! This imports tags from Simple Tagging 1.6.2 into WordPress tags.').'</p>'; echo '<p>'.__('This has not been tested on any other versions of Simple Tagging. Mileage may vary.').'</p>'; echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 4-step program to help you kick that nasty Simple Tagging habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>'; echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>'; echo '<form action="admin.php?import=stp&step=1" method="post">'; wp_nonce_field('import-stp'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -70,15 +70,15 @@ class STP_Import { if ( get_option('stpimp_posts') ) { delete_option('stpimp_posts'); } - + add_option('stpimp_posts', $posts); $count = count($posts); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag to post relationships were read.', 'Done! <strong>%s</strong> tags to post relationships were read.', $count), $count ) . '<br /></p>'; } echo '<form action="admin.php?import=stp&step=2" method="post">'; wp_nonce_field('import-stp'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -87,14 +87,14 @@ class STP_Import { function import_t2p ( ) { echo '<div class="narrow">'; echo '<p><h3>'.__('Adding Tags to Posts…').'</h3></p>'; - + // run that funky magic! $tags_added = $this->tag2post(); - - echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>'; + + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag was added!', 'Done! <strong>%s</strong> tags were added!', $tags_added), $tags_added ) . '<br /></p>'; echo '<form action="admin.php?import=stp&step=3" method="post">'; wp_nonce_field('import-stp'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -151,5 +151,5 @@ class STP_Import { $stp_import = new STP_Import(); // add it to the import page! -register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into the new native tagging structure.'), array($stp_import, 'dispatch')); -?>
\ No newline at end of file +register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into WordPress tags.'), array($stp_import, 'dispatch')); +?> diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php index 1fe54c8..1c10015 100644 --- a/wp-admin/import/textpattern.php +++ b/wp-admin/import/textpattern.php @@ -46,7 +46,7 @@ class Textpattern_Import { echo '<form action="admin.php?import=textpattern&step=1" method="post">'; wp_nonce_field('import-textpattern'); $this->db_form(); - echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>'; + echo '<p class="submit"><input type="submit" class="button" name="submit" value="'.attribute_escape(__('Import')).'" /></p>'; echo '</form>'; echo '</div>'; } @@ -177,7 +177,7 @@ class Textpattern_Import { // Store category translation for future use add_option('txpcat2wpcat',$txpcat2wpcat); - echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>'; + echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>'; return true; } echo __('No Categories to Import!'); @@ -462,7 +462,7 @@ class Textpattern_Import { } add_option('txplinks2wplinks',$txplinks2wplinks); echo '<p>'; - printf(__('Done! <strong>%s</strong> Links imported'), $count); + printf(__ngettext('Done! <strong>%s</strong> link imported', 'Done! <strong>%s</strong> links imported', $count), $count); echo '<br /><br /></p>'; return true; } @@ -481,7 +481,7 @@ class Textpattern_Import { echo '<form action="admin.php?import=textpattern&step=2" method="post">'; wp_nonce_field('import-textpattern'); - printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users'))); + printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Users'))); echo '</form>'; } @@ -494,7 +494,7 @@ class Textpattern_Import { echo '<form action="admin.php?import=textpattern&step=3" method="post">'; wp_nonce_field('import-textpattern'); - printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts'))); + printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Posts'))); echo '</form>'; } @@ -508,7 +508,7 @@ class Textpattern_Import { echo '<form action="admin.php?import=textpattern&step=4" method="post">'; wp_nonce_field('import-textpattern'); - printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments'))); + printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Comments'))); echo '</form>'; } @@ -520,7 +520,7 @@ class Textpattern_Import { echo '<form action="admin.php?import=textpattern&step=5" method="post">'; wp_nonce_field('import-textpattern'); - printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links'))); + printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Links'))); echo '</form>'; } @@ -533,7 +533,7 @@ class Textpattern_Import { echo '<form action="admin.php?import=textpattern&step=6" method="post">'; wp_nonce_field('import-textpattern'); - printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish'))); + printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Finish'))); echo '</form>'; } @@ -550,6 +550,7 @@ class Textpattern_Import { delete_option('txppass'); delete_option('txpname'); delete_option('txphost'); + do_action('import_done', 'textpattern'); $this->tips(); } @@ -574,7 +575,7 @@ class Textpattern_Import { function db_form() { - echo '<table class="editform">'; + echo '<table class="form-table">'; printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Textpattern Database User:')); printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Textpattern Database Password:')); printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Textpattern Database Name:')); @@ -645,7 +646,7 @@ class Textpattern_Import { break; case 3 : $result = $this->import_posts(); - if ( is_wp_error( $result ) ) + if ( is_wp_error( $result ) ) echo $result->get_error_message(); break; case 4 : @@ -669,5 +670,5 @@ class Textpattern_Import { } $txp_import = new Textpattern_Import(); -register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog'), array ($txp_import, 'dispatch')); +register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog.'), array ($txp_import, 'dispatch')); ?> diff --git a/wp-admin/import/utw.php b/wp-admin/import/utw.php index 120f50c..759809e 100644 --- a/wp-admin/import/utw.php +++ b/wp-admin/import/utw.php @@ -14,12 +14,12 @@ class UTW_Import { function greet() { echo '<div class="narrow">'; - echo '<p>'.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'</p>'; + echo '<p>'.__('Howdy! This imports tags from Ultimate Tag Warrior 3 into WordPress tags.').'</p>'; echo '<p>'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'</p>'; echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>'; echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>'; echo '<form action="admin.php?import=utw&step=1" method="post">'; - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -84,7 +84,7 @@ class UTW_Import { $count = count($tags); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag were read.', 'Done! <strong>%s</strong> tags were read.', $count), $count ) . '<br /></p>'; echo '<p>' . __('The following tags were found:') . '</p>'; echo '<ul>'; @@ -106,7 +106,7 @@ class UTW_Import { echo '<form action="admin.php?import=utw&step=2" method="post">'; wp_nonce_field('import-utw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2').'" /></p>'; echo '</form>'; echo '</div>'; } @@ -136,13 +136,13 @@ class UTW_Import { $count = count($posts); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag to post relationships were read.', 'Done! <strong>%s</strong> tags to post relationships were read.', $count), $count ) . '<br /></p>'; } echo '<form action="admin.php?import=utw&step=3" method="post">'; wp_nonce_field('import-utw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3').'" /></p>'; echo '</form>'; echo '</div>'; @@ -157,11 +157,11 @@ class UTW_Import { // run that funky magic! $tags_added = $this->tag2post(); - echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were added!'), $tags_added ) . '<br /></p>'; + echo '<p>' . sprintf( __ngettext( 'Done! <strong>%s</strong> tag were added!', 'Done! <strong>%s</strong> tags were added!', $tags_added ), $tags_added ) . '<br /></p>'; echo '<form action="admin.php?import=utw&step=4" method="post">'; wp_nonce_field('import-utw'); - echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4 »').'" /></p>'; + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4').'" /></p>'; echo '</form>'; echo '</div>'; @@ -271,6 +271,6 @@ class UTW_Import { $utw_import = new UTW_Import(); // add it to the import page! -register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch')); +register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into WordPress tags.'), array($utw_import, 'dispatch')); ?> diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index dca1c73..03395bd 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -2,14 +2,21 @@ class WP_Import { - var $posts = array (); - var $posts_processed = array (); - // Array of arrays. [[0] => XML fragment, [1] => New post ID] + var $post_ids_processed = array (); + var $orphans = array (); var $file; var $id; var $mtnames = array (); var $newauthornames = array (); + var $allauthornames = array (); + + var $author_ids = array (); + var $tags = array (); + var $categories = array (); + var $j = -1; + var $fetch_attachments = false; + var $url_remap = array (); function header() { echo '<div class="wrap">'; @@ -42,44 +49,48 @@ class WP_Import { return $return; } - function users_form($n) { - global $wpdb, $testing; - $users = get_users_of_blog($wpdb->blogid); -?><select name="userselect[<?php echo attribute_escape($n); ?>]"> - <option value="#NONE#">- Select -</option> - <?php - foreach ($users as $user) { - echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>'; - } -?> - </select> - <?php + function has_gzip() { + return is_callable('gzopen'); } - //function to check the authorname and do the mapping - function checkauthor($author) { - global $wpdb; + function fopen($filename, $mode='r') { + if ( $this->has_gzip() ) + return gzopen($filename, $mode); + return fopen($filename, $mode); + } - $map = $_POST['userselect']; + function feof($fp) { + if ( $this->has_gzip() ) + return gzeof($fp); + return feof($fp); + } - $user_id = username_exists($map[$author]); //use that key to get the value of the author's name from $newauthornames + function fgets($fp, $len=8192) { + if ( $this->has_gzip() ) + return gzgets($fp, $len); + return fgets($fp, $len); + } - return $user_id; + function fclose($fp) { + if ( $this->has_gzip() ) + return gzclose($fp); + return fclose($fp); } - function get_entries() { + function get_entries($process_post_func=NULL) { set_magic_quotes_runtime(0); - $this->posts = array(); - $this->categories = array(); - $this->tags = array(); - $num = 0; $doing_entry = false; + $is_wxr_file = false; - $fp = fopen($this->file, 'r'); + $fp = $this->fopen($this->file, 'r'); if ($fp) { - while ( !feof($fp) ) { - $importline = rtrim(fgets($fp)); + while ( !$this->feof($fp) ) { + $importline = rtrim($this->fgets($fp)); + + // this doesn't check that the file is perfectly valid but will at least confirm that it's not the wrong format altogether + if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) ) + $is_wxr_file = true; if ( false !== strpos($importline, '<wp:category>') ) { preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); @@ -92,44 +103,31 @@ class WP_Import { continue; } if ( false !== strpos($importline, '<item>') ) { - $this->posts[$num] = ''; + $this->post = ''; $doing_entry = true; continue; } if ( false !== strpos($importline, '</item>') ) { - $num++; $doing_entry = false; + if ($process_post_func) + call_user_func($process_post_func, $this->post); continue; } if ( $doing_entry ) { - $this->posts[$num] .= $importline . "\n"; - } - } - - foreach ($this->posts as $post) { - $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); - if ($post_ID) { - $this->posts_processed[$post_ID][0] = &$post; - $this->posts_processed[$post_ID][1] = 0; + $this->post .= $importline . "\n"; } } - fclose($fp); + $this->fclose($fp); } + + return $is_wxr_file; + } function get_wp_authors() { - $temp = array (); - $i = -1; - foreach ($this->posts as $post) { - if ('' != trim($post)) { - ++ $i; - $author = $this->get_tag( $post, 'dc:creator' ); - array_push($temp, "$author"); //store the extracted author names in a temporary array - } - } - // We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting. + $temp = $this->allauthornames; $authors[0] = array_shift($temp); $y = count($temp) + 1; for ($x = 1; $x < $y; $x ++) { @@ -142,36 +140,50 @@ class WP_Import { } function get_authors_from_post() { - $formnames = array (); - $selectnames = array (); - - foreach ((array)$_POST['user'] as $key => $line) { - $newname = trim(stripslashes($line)); - if ($newname == '') - $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form. - array_push($formnames, "$newname"); - } // $formnames is the array with the form entered names - - foreach ($_POST['userselect'] as $user => $key) { - $selected = trim(stripslashes($key)); - array_push($selectnames, "$selected"); - } + global $current_user; + + // this will populate $this->author_ids with a list of author_names => user_ids - $count = count($formnames); - for ($i = 0; $i < $count; $i ++) { - if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form - array_push($this->newauthornames, "$selectnames[$i]"); - } else { - array_push($this->newauthornames, "$formnames[$i]"); + foreach ( $_POST['author_in'] as $i => $in_author_name ) { + + if ( !empty($_POST['user_select'][$i]) ) { + // an existing user was selected in the dropdown list + $user = get_userdata( intval($_POST['user_select'][$i]) ); + if ( isset($user->ID) ) + $this->author_ids[$in_author_name] = $user->ID; + } + elseif ( $this->allow_create_users() ) { + // nothing was selected in the dropdown list, so we'll use the name in the text field + + $new_author_name = trim($_POST['user_create'][$i]); + // if the user didn't enter a name, assume they want to use the same name as in the import file + if ( empty($new_author_name) ) + $new_author_name = $in_author_name; + + $user_id = username_exists($new_author_name); + if ( !$user_id ) { + $user_id = wp_create_user($new_author_name, wp_generate_password()); + } + + $this->author_ids[$in_author_name] = $user_id; + } + + // failsafe: if the user_id was invalid, default to the current user + if ( empty($this->author_ids[$in_author_name]) ) { + $this->author_ids[$in_author_name] = intval($current_user->ID); } } + } function wp_authors_form() { ?> <h2><?php _e('Assign Authors'); ?></h2> <p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p> - <?php +<?php + if ( $this->allow_create_users() ) { + echo '<p>'.__('If a new user is created by WordPress, a password will be randomly generated. Manually change the user\'s details if necessary.')."</p>\n"; + } $authors = $this->get_wp_authors(); @@ -181,31 +193,76 @@ class WP_Import { $j = -1; foreach ($authors as $author) { ++ $j; - echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.'Map to existing: '; - $this->users_form($author); + echo '<li>'.__('Import author:').' <strong>'.$author.'</strong><br />'; + $this->users_form($j, $author); echo '</li>'; } - echo '<input type="submit" value="Submit">'.'<br />'; + if ( $this->allow_fetch_attachments() ) { +?> +</ol> +<h2><?php _e('Import Attachments'); ?></h2> +<p> + <input type="checkbox" value="1" name="attachments" id="import-attachments" /> + <label for="import-attachments"><?php _e('Download and import file attachments') ?></label> +</p> + +<?php + } + + echo '<input type="submit" value="'.attribute_escape( __('Submit') ).'">'.'<br />'; echo '</form>'; - echo '</ol>'; } + function users_form($n, $author) { + + if ( $this->allow_create_users() ) { + printf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user_create['.intval($n).']'.'" maxlength="30"> <br />'); + } + else { + echo __('Map to existing').'<br />'; + } + + // keep track of $n => $author name + echo '<input type="hidden" name="author_in['.intval($n).']" value="'.htmlspecialchars($author).'" />'; + + $users = get_users_of_blog(); +?><select name="user_select[<?php echo $n; ?>]"> + <option value="0"><?php _e('- Select -'); ?></option> + <?php + foreach ($users as $user) { + echo '<option value="'.$user->user_id.'">'.$user->user_login.'</option>'; + } +?> + </select> + <?php + } + function select_authors() { - $file = wp_import_handle_upload(); - if ( isset($file['error']) ) { - echo '<p>'.__('Sorry, there has been an error.').'</p>'; - echo '<p><strong>' . $file['error'] . '</strong></p>'; - return; + $is_wxr_file = $this->get_entries(array(&$this, 'process_author')); + if ( $is_wxr_file ) { + $this->wp_authors_form(); } - $this->file = $file['file']; - $this->id = (int) $file['id']; + else { + echo '<h2>'.__('Invalid file').'</h2>'; + echo '<p>'.__('Please upload a valid WXR (WordPress eXtended RSS) export file.').'</p>'; + } + } - $this->get_entries(); - $this->wp_authors_form(); + // fetch the user ID for a given author name, respecting the mapping preferences + function checkauthor($author) { + global $current_user; + + if ( !empty($this->author_ids[$author]) ) + return $this->author_ids[$author]; + + // failsafe: map to the current user + return $current_user->ID; } + + function process_categories() { global $wpdb; @@ -256,19 +313,22 @@ class WP_Import { } } + function process_author($post) { + $author = $this->get_tag( $post, 'dc:creator' ); + if ($author) + $this->allauthornames[] = $author; + } + function process_posts() { $i = -1; echo '<ol>'; - foreach ($this->posts as $post) { - $result = $this->process_post($post); - if ( is_wp_error( $result ) ) - return $result; - } + $this->get_entries(array(&$this, 'process_post')); echo '</ol>'; wp_import_cleanup($this->id); + do_action('import_done', 'wordpress'); echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>'; } @@ -277,8 +337,10 @@ class WP_Import { global $wpdb; $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); - if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already + if ( $post_ID && !empty($this->post_ids_processed[$post_ID]) ) // Processed already return 0; + + set_time_limit( 60 ); // There are only ever one of these $post_title = $this->get_tag( $post, 'title' ); @@ -291,6 +353,7 @@ class WP_Import { $post_parent = $this->get_tag( $post, 'wp:post_parent' ); $menu_order = $this->get_tag( $post, 'wp:menu_order' ); $post_type = $this->get_tag( $post, 'wp:post_type' ); + $post_password = $this->get_tag( $post, 'wp:post_password' ); $guid = $this->get_tag( $post, 'guid' ); $post_author = $this->get_tag( $post, 'dc:creator' ); @@ -317,35 +380,52 @@ class WP_Import { $cat_index++; } - if ($post_id = post_exists($post_title, '', $post_date)) { + $post_exists = post_exists($post_title, '', $post_date); + + if ( $post_exists ) { echo '<li>'; - printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); + printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title)); } else { // If it has parent, process parent first. $post_parent = (int) $post_parent; - if ($parent = $this->posts_processed[$post_parent]) { - if (!$parent[1]) { - $result = $this->process_post($parent[0]); // If not yet, process the parent first. - if ( is_wp_error( $result ) ) - return $result; + if ($post_parent) { + // if we already know the parent, map it to the local ID + if ( $parent = $this->post_ids_processed[$post_parent] ) { + $post_parent = $parent; // new ID of the parent + } + else { + // record the parent for later + $this->orphans[intval($post_ID)] = $post_parent; } - $post_parent = $parent[1]; // New ID of the parent; } echo '<li>'; - printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor - $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type'); - $comment_post_ID = $post_id = wp_insert_post($postdata); + $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password'); + if ($post_type == 'attachment') { + $remote_url = $this->get_tag( $post, 'wp:attachment_url' ); + if ( !$remote_url ) + $remote_url = $guid; + + $comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url); + if ( !$post_id or is_wp_error($post_id) ) + return $post_id; + } + else { + printf(__('Importing post <em>%s</em>...'), stripslashes($post_title)); + $comment_post_ID = $post_id = wp_insert_post($postdata); + } + if ( is_wp_error( $post_id ) ) return $post_id; // Memorize old and new ID. - if ( $post_id && $post_ID && $this->posts_processed[$post_ID] ) - $this->posts_processed[$post_ID][1] = $post_id; // New ID. + if ( $post_id && $post_ID ) { + $this->post_ids_processed[intval($post_ID)] = intval($post_id); + } // Add categories. if (count($categories) > 0) { @@ -379,7 +459,7 @@ class WP_Import { $tag_id = wp_insert_term($tag, 'post_tag'); $tag_id = $tag_id['term_id']; } - $post_tags[] = intval( $tag_id ); + $post_tags[] = intval($tag_id); } wp_set_post_tags($post_id, $post_tags); } @@ -401,7 +481,8 @@ class WP_Import { $comment_type = $this->get_tag( $comment, 'wp:comment_type'); $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); - if ( !comment_exists($comment_author, $comment_date) ) { + // if this is a new post we can skip the comment_exists() check + if ( !$post_exists || !comment_exists($comment_author, $comment_date) ) { $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); wp_insert_comment($commentdata); $num_comments++; @@ -409,7 +490,7 @@ class WP_Import { } } if ( $num_comments ) - printf(' '.__('(%s comments)'), $num_comments); + printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); // Now for post meta preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta); @@ -418,23 +499,217 @@ class WP_Import { $key = $this->get_tag( $p, 'wp:meta_key' ); $value = $this->get_tag( $p, 'wp:meta_value' ); $value = stripslashes($value); // add_post_meta() will escape. - add_post_meta( $post_id, $key, $value ); + + $this->process_post_meta($post_id, $key, $value); + } } + + do_action('import_post_added', $post_id); + print "</li>\n"; } - function import() { - $this->id = (int) $_GET['id']; + function process_post_meta($post_id, $key, $value) { + // the filter can return false to skip a particular metadata key + $_key = apply_filters('import_post_meta_key', $key); + if ( $_key ) { + add_post_meta( $post_id, $_key, $value ); + do_action('import_post_meta', $post_id, $_key, $value); + } + } + + function process_attachment($postdata, $remote_url) { + if ($this->fetch_attachments and $remote_url) { + printf( __('Importing attachment <em>%s</em>... '), htmlspecialchars($remote_url) ); + $upload = $this->fetch_remote_file($postdata, $remote_url); + if ( is_wp_error($upload) ) { + printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) ); + return $upload; + } + else { + print '('.size_format(filesize($upload['file'])).')'; + } + + if ( $info = wp_check_filetype($upload['file']) ) { + $postdata['post_mime_type'] = $info['type']; + } + else { + print __('Invalid file type'); + return; + } + + $postdata['guid'] = $upload['url']; + + // as per wp-admin/includes/upload.php + $post_id = wp_insert_attachment($postdata, $upload['file']); + wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); + + // remap the thumbnail url. this isn't perfect because we're just guessing the original url. + if ( preg_match('@^image/@', $info['type']) && $thumb_url = wp_get_attachment_thumb_url($post_id) ) { + $parts = pathinfo($remote_url); + $ext = $parts['extension']; + $name = basename($parts['basename'], ".{$ext}"); + $this->url_remap[$parts['dirname'] . '/' . $name . '.thumbnail.' . $ext] = $thumb_url; + } + + return $post_id; + } + else { + printf( __('Skipping attachment <em>%s</em>'), htmlspecialchars($remote_url) ); + } + } + + function fetch_remote_file($post, $url) { + $upload = wp_upload_dir($post['post_date']); + + // extract the file name and extension from the url + $file_name = basename($url); + + // get placeholder file in the upload dir with a unique sanitized filename + $upload = wp_upload_bits( $file_name, 0, '', $post['post_date']); + if ( $upload['error'] ) { + echo $upload['error']; + return new WP_Error( 'upload_dir_error', $upload['error'] ); + } + + // fetch the remote url and write it to the placeholder file + $headers = wp_get_http($url, $upload['file']); + + // make sure the fetch was successful + if ( $headers['response'] != '200' ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %d'), intval($headers['response'])) ); + } + elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', __('Remote file is incorrect size') ); + } + + $max_size = $this->max_attachment_size(); + if ( !empty($max_size) and filesize($upload['file']) > $max_size ) { + @unlink($upload['file']); + return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', size_format($max_size))) ); + } + + // keep track of the old and new urls so we can substitute them later + $this->url_remap[$url] = $upload['url']; + // if the remote url is redirected somewhere else, keep track of the destination too + if ( $headers['x-final-location'] != $url ) + $this->url_remap[$headers['x-final-location']] = $upload['url']; + + return $upload; + + } + + // sort by strlen, longest string first + function cmpr_strlen($a, $b) { + return strlen($b) - strlen($a); + } + + // update url references in post bodies to point to the new local files + function backfill_attachment_urls() { + + // make sure we do the longest urls first, in case one is a substring of another + uksort($this->url_remap, array(&$this, 'cmpr_strlen')); - $this->file = get_attached_file($this->id); + global $wpdb; + foreach ($this->url_remap as $from_url => $to_url) { + // remap urls in post_content + $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, '%s', '%s')", $from_url, $to_url) ); + // remap enclosure urls + $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, '%s', '%s') WHERE meta_key='enclosure'", $from_url, $to_url) ); + } + } + + // update the post_parent of orphans now that we know the local id's of all parents + function backfill_parents() { + global $wpdb; + + foreach ($this->orphans as $child_id => $parent_id) { + $local_child_id = $this->post_ids_processed[$child_id]; + $local_parent_id = $this->post_ids_processed[$parent_id]; + if ($local_child_id and $local_parent_id) { + $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $local_parent_id, $local_child_id)); + } + } + } + + function is_valid_meta_key($key) { + // skip _wp_attached_file metadata since we'll regenerate it from scratch + if ( $key == '_wp_attached_file' ) + return false; + return $key; + } + + // give the user the option of creating new users to represent authors in the import file? + function allow_create_users() { + return apply_filters('import_allow_create_users', true); + } + + // give the user the option of downloading and importing attached files + function allow_fetch_attachments() { + return apply_filters('import_allow_fetch_attachments', true); + } + + function max_attachment_size() { + // can be overridden with a filter - 0 means no limit + return apply_filters('import_attachment_size_limit', 0); + } + + function import_start() { + wp_defer_term_counting(true); + wp_defer_comment_counting(true); + do_action('import_start'); + } + + function import_end() { + do_action('import_end'); + + // clear the caches after backfilling + foreach ($this->post_ids_processed as $post_id) + clean_post_cache($post_id); + + wp_defer_term_counting(false); + wp_defer_comment_counting(false); + } + + function import($id, $fetch_attachments = false) { + $this->id = (int) $id; + $this->fetch_attachments = ($this->allow_fetch_attachments() && (bool) $fetch_attachments); + + add_filter('import_post_meta_key', array($this, 'is_valid_meta_key')); + $file = get_attached_file($this->id); + $this->import_file($file); + } + + function import_file($file) { + $this->file = $file; + + $this->import_start(); $this->get_authors_from_post(); $this->get_entries(); $this->process_categories(); $this->process_tags(); $result = $this->process_posts(); + $this->backfill_parents(); + $this->backfill_attachment_urls(); + $this->import_end(); + if ( is_wp_error( $result ) ) return $result; } + function handle_upload() { + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo '<p>'.__('Sorry, there has been an error.').'</p>'; + echo '<p><strong>' . $file['error'] . '</strong></p>'; + return false; + } + $this->file = $file['file']; + $this->id = (int) $file['id']; + return true; + } + function dispatch() { if (empty ($_GET['step'])) $step = 0; @@ -448,11 +723,12 @@ class WP_Import { break; case 1 : check_admin_referer('import-upload'); - $this->select_authors(); + if ( $this->handle_upload() ) + $this->select_authors(); break; case 2: check_admin_referer('import-wordpress'); - $result = $this->import(); + $result = $this->import( $_GET['id'], $_POST['attachments'] ); if ( is_wp_error( $result ) ) echo $result->get_error_message(); break; @@ -467,6 +743,6 @@ class WP_Import { $wp_import = new WP_Import(); -register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch')); +register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file.'), array ($wp_import, 'dispatch')); ?> diff --git a/wp-admin/import/wp-cat2tag.php b/wp-admin/import/wp-cat2tag.php index d38e17a..246125e 100644 --- a/wp-admin/import/wp-cat2tag.php +++ b/wp-admin/import/wp-cat2tag.php @@ -5,12 +5,12 @@ class WP_Categories_to_Tags { var $all_categories = array(); function header() { - print '<div class="wrap">'; - print '<h2>' . __('Convert Categories to Tags') . '</h2>'; + echo '<div class="wrap">'; + echo '<h2>' . __('Convert Categories to Tags') . '</h2>'; } function footer() { - print '</div>'; + echo '</div>'; } function populate_all_categories() { @@ -19,75 +19,101 @@ class WP_Categories_to_Tags { $categories = get_categories('get=all'); foreach ( $categories as $category ) { if ( !tag_exists($wpdb->escape($category->name)) ) - $this->all_categories[] = $category; + $this->all_categories[] = $category; } } function welcome() { $this->populate_all_categories(); - print '<div class="narrow">'; + echo '<div class="narrow">'; if (count($this->all_categories) > 0) { - print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>'; - print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>'; + echo '<p>' . __('Hey there. Here you can selectively converts existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '</p>'; + echo '<p>' . __('Keep in mind that if you convert a category with child categories, the children become top-level orphans.') . '</p>'; $this->categories_form(); } else { - print '<p>'.__('You have no categories to convert!').'</p>'; + echo '<p>'.__('You have no categories to convert!').'</p>'; } - print '</div>'; + echo '</div>'; } function categories_form() { - print '<form action="admin.php?import=wp-cat2tag&step=2" method="post">'; +?> +<script type="text/javascript"> +<!-- +var checkflag = "false"; +function check_all_rows() { + field = document.formlist; + if ( 'false' == checkflag ) { + for ( i = 0; i < field.length; i++ ) { + if ( 'cats_to_convert[]' == field[i].name ) + field[i].checked = true; + } + checkflag = 'true'; + return '<?php _e('Uncheck All') ?>'; + } else { + for ( i = 0; i < field.length; i++ ) { + if ( 'cats_to_convert[]' == field[i].name ) + field[i].checked = false; + } + checkflag = 'false'; + return '<?php _e('Check All') ?>'; + } +} + +// --> +</script> +<?php + echo '<form name="formlist" id="formlist" action="admin.php?import=wp-cat2tag&step=2" method="post"> + <p><input type="button" class="button-secondary" value="' . __('Check All') . '"' . ' onClick="this.value=check_all_rows()"></p>'; wp_nonce_field('import-cat2tag'); - print '<ul style="list-style:none">'; + echo '<ul style="list-style:none">'; $hier = _get_term_hierarchy('category'); foreach ($this->all_categories as $category) { $category = sanitize_term( $category, 'category', 'display' ); - + if ((int) $category->parent == 0) { - print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>'; + echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>'; if (isset($hier[$category->term_id])) { $this->_category_children($category, $hier); } - print '</li>'; + echo '</li>'; } } - print '</ul>'; + echo '</ul>'; + + echo '<p class="submit"><input type="submit" name="submit" class="button" value="' . __('Convert Tags') . '" /></p>'; - print '<p class="submit"><input type="submit" name="submit" value="' . __('Convert »') . '" /></p>'; - print '</form>'; + echo '</form>'; } function _category_children($parent, $hier) { - print '<ul style="list-style:none">'; + echo '<ul style="list-style:none">'; foreach ($hier[$parent->term_id] as $child_id) { $child =& get_category($child_id); - print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>'; + echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>'; if (isset($hier[$child->term_id])) { $this->_category_children($child, $hier); } - print '</li>'; + echo '</li>'; } - print '</ul>'; + echo '</ul>'; } function _category_exists($cat_id) { - global $wpdb; - $cat_id = (int) $cat_id; $maybe_exists = category_exists($cat_id); @@ -103,9 +129,9 @@ class WP_Categories_to_Tags { global $wpdb; if ( (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) { - print '<div class="narrow">'; - print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>'; - print '</div>'; + echo '<div class="narrow">'; + echo '<p>' . sprintf(__('Uh, oh. Something didn’t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>'; + echo '</div>'; return; } @@ -114,12 +140,12 @@ class WP_Categories_to_Tags { $this->categories_to_convert = $_POST['cats_to_convert']; $hier = _get_term_hierarchy('category'); - print '<ul>'; + echo '<ul>'; foreach ( (array) $this->categories_to_convert as $cat_id) { $cat_id = (int) $cat_id; - print '<li>' . sprintf(__('Converting category #%s ... '), $cat_id); + echo '<li>' . sprintf(__('Converting category #%s ... '), $cat_id); if (!$this->_category_exists($cat_id)) { _e('Category doesn\'t exist!'); @@ -128,7 +154,7 @@ class WP_Categories_to_Tags { if ( tag_exists($wpdb->escape($category->name)) ) { _e('Category is already a tag.'); - print '</li>'; + echo '</li>'; continue; } @@ -138,7 +164,7 @@ class WP_Categories_to_Tags { $id = $id['term_taxonomy_id']; $posts = get_objects_in_term($category->term_id, 'category'); foreach ( $posts as $post ) { - if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") ) + if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") ) $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')"); clean_post_cache($post); } @@ -166,10 +192,11 @@ class WP_Categories_to_Tags { _e('Converted successfully.'); } - print '</li>'; + echo '</li>'; } - print '</ul>'; + echo '</ul>'; + echo '<p>' . sprintf( __('We’re all done here, but you can always <a href="%s">convert more</a>.'), 'admin.php?import=wp-cat2tag' ) . '</p>'; } function init() { @@ -179,9 +206,9 @@ class WP_Categories_to_Tags { $this->header(); if (!current_user_can('manage_categories')) { - print '<div class="narrow">'; - print '<p>' . __('Cheatin’ uh?') . '</p>'; - print '</div>'; + echo '<div class="narrow">'; + echo '<p>' . __('Cheatin’ uh?') . '</p>'; + echo '</div>'; } else { if ( $step > 1 ) check_admin_referer('import-cat2tag'); diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php index 04a4bc1..7f1c12c 100644 --- a/wp-admin/includes/admin.php +++ b/wp-admin/includes/admin.php @@ -1,9 +1,13 @@ <?php +if ( !defined( 'AUTOSAVE_INTERVAL' ) ) + define( 'AUTOSAVE_INTERVAL', 60 ); + require_once(ABSPATH . 'wp-admin/includes/bookmark.php'); require_once(ABSPATH . 'wp-admin/includes/comment.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); +require_once(ABSPATH . 'wp-admin/includes/media.php'); require_once(ABSPATH . 'wp-admin/includes/import.php'); require_once(ABSPATH . 'wp-admin/includes/misc.php'); require_once(ABSPATH . 'wp-admin/includes/plugin.php'); diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 35cc9c9..2cae3b5 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -13,6 +13,8 @@ function edit_link( $link_id = '' ) { $_POST['link_name'] = wp_specialchars( $_POST['link_name'] ); $_POST['link_image'] = wp_specialchars( $_POST['link_image'] ); $_POST['link_rss'] = clean_url($_POST['link_rss']); + if ( 'N' != $_POST['link_visible'] ) + $_POST['link_visible'] = 'Y'; if ( !empty( $link_id ) ) { $_POST['link_id'] = $link_id; @@ -60,7 +62,7 @@ function wp_get_link_cats($link_id = 0) { } function get_link_to_edit( $link_id ) { - return get_link( $link_id, OBJECT, 'edit' ); + return get_bookmark( $link_id, OBJECT, 'edit' ); } function wp_insert_link($linkdata) { @@ -151,8 +153,6 @@ function wp_set_link_cats($link_id = 0, $link_categories = array()) { } // wp_set_link_cats() function wp_update_link($linkdata) { - global $wpdb; - $link_id = (int) $linkdata['link_id']; $link = get_link($link_id, ARRAY_A); @@ -174,4 +174,4 @@ function wp_update_link($linkdata) { return wp_insert_link($linkdata); } -?>
\ No newline at end of file +?> diff --git a/wp-admin/includes/class-ftp.php b/wp-admin/includes/class-ftp.php index bc2720a..c10526b 100644 --- a/wp-admin/includes/class-ftp.php +++ b/wp-admin/includes/class-ftp.php @@ -317,7 +317,7 @@ class ftp_base { function pwd() { if(!$this->_exec("PWD", "pwd")) return FALSE; if(!$this->_checkCode()) return FALSE; - return ereg_replace("^[0-9]{3} \"(.+)\" .+".CRLF, "\\1", $this->_message); + return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message); } function cdup() { diff --git a/wp-admin/includes/class-pclzip.php b/wp-admin/includes/class-pclzip.php index d387f00..b490744 100644 --- a/wp-admin/includes/class-pclzip.php +++ b/wp-admin/includes/class-pclzip.php @@ -4470,7 +4470,9 @@ $v_byte = @fread($this->zip_fd, 1); // ----- Add the byte - $v_bytes = ($v_bytes << 8) | Ord($v_byte); + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); // ----- Compare the bytes if ($v_bytes == 0x504b0506) diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index d698b20..dc74f52 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -8,7 +8,7 @@ class WP_Filesystem_Direct{ $this->permission = umask(); } function connect(){ - return; + return true; } function setDefaultPermissions($perm){ $this->permission = $perm; @@ -17,7 +17,7 @@ class WP_Filesystem_Direct{ return str_replace('\\','/',ABSPATH); } function get_base_dir($base = '.', $echo = false){ - return find_base_dir($base, $echo); + return $this->find_base_dir($base, $echo); } function get_contents($file){ return @file_get_contents($file); diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index a8a3585..32ccd07 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -84,48 +84,67 @@ class WP_Filesystem_FTPext{ $this->permission = $perm; } - function find_base_dir($base = '.',$echo = false){ + function find_base_dir($base = '.',$echo = false, $loop = false) { + //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) $abspath = $mat[1]; } + //Set up the base directory (Which unless specified, is the current one) if( empty( $base ) || '.' == $base ) $base = $this->cwd(); - if( empty( $base ) ) $base = '/'; - if( '/' != substr($base, -1) ) $base .= '/'; - - if($echo) echo __('Changing to ') . $base .'<br>'; - if( false === $this->chdir($base) ) - return false; - - if( $this->exists($base . 'wp-settings.php') ){ - if($echo) echo __('Found ') . $base . 'wp-settings.php<br>'; - $this->wp_base = $base; - return $this->wp_base; + $base = trailingslashit($base); + + //Can we see the Current directory as part of the ABSPATH? + $location = strpos($abspath, $base); + if( false !== $location ) { + $newbase = path_join($base, substr($abspath, $location + strlen($base))); + + if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly. + if($echo) printf( __('Changing to %s') . '<br/>', $newbase ); + //Check to see if it exists in that folder. + if( $this->exists($newbase . 'wp-settings.php') ){ + if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php<br/>' ); + return $newbase; + } + } } - - if( strpos($abspath, $base) > 0) - $arrPath = split('/',substr($abspath,strpos($abspath, $base))); - else - $arrPath = split('/',$abspath); - - for($i = 0; $i <= count($arrPath); $i++) - if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] ); - - foreach($arrPath as $key=>$folder){ - if( $this->is_dir($base . $folder) ){ - if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/<br>'; - return $this->find_base_dir($base . $folder . '/',$echo); + + //Ok, Couldnt do a magic location from that particular folder level + + //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. + $files = $this->dirlist($base); + + $arrPath = explode('/', $abspath); + foreach($arrPath as $key){ + //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, + // If its found, change into it and follow through looking for it. + // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. + // If it reaches the end, and still cant find it, it'll return false for the entire function. + if( isset($files[ $key ]) ){ + //Lets try that folder: + $folder = path_join($base, $key); + if($echo) printf( __('Changing to %s') . '<br/>', $folder ); + $ret = $this->find_base_dir( $folder, $echo, $loop); + if( $ret ) + return $ret; } } - - if( $base == '/' ) - return false; - //If we get this far, somethings gone wrong, change to / and restart the process. - return $this->find_base_dir('/',$echo); + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ 'wp-settings.php' ]) ){ + if($echo) printf( __('Found %s'), $base . 'wp-settings.php<br/>' ); + return $base; + } + if( $loop ) + return false;//Prevent tihs function looping again. + //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups. + return $this->find_base_dir('/', $echo, true); } - function get_base_dir($base = '.', $echo=false){ + + function get_base_dir($base = '.', $echo = false){ + if( defined('FTP_BASE') ) + $this->wp_base = FTP_BASE; if( empty($this->wp_base) ) $this->wp_base = $this->find_base_dir($base,$echo); return $this->wp_base; @@ -136,6 +155,8 @@ class WP_Filesystem_FTPext{ $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; } $temp = tmpfile(); + if ( ! $temp ) + return false; if( ! @ftp_fget($this->link,$temp,$file,$type,$resumepos) ) return false; fseek($temp, 0); //Skip back to the start of the file being written to @@ -151,10 +172,12 @@ class WP_Filesystem_FTPext{ } function put_contents($file,$contents,$type=''){ if( empty($type) ){ - $extension = substr(strrchr($filename, "."), 1); + $extension = substr(strrchr($file, "."), 1); $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; } $temp = tmpfile(); + if ( ! $temp ) + return false; fwrite($temp,$contents); fseek($temp, 0); //Skip back to the start of the file being written to $ret = @ftp_fput($this->link,$file,$temp,$type); @@ -162,7 +185,10 @@ class WP_Filesystem_FTPext{ return $ret; } function cwd(){ - return ftp_pwd($this->link); + $cwd = ftp_pwd($this->link); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; } function chdir($dir){ return @ftp_chdir($dir); @@ -308,8 +334,9 @@ class WP_Filesystem_FTPext{ } function is_dir($path){ $cwd = $this->cwd(); - @ftp_chdir($this->link, $path); - if ( $this->cwd() != $cwd ) { + $result = @ftp_chdir($this->link, $path); + if( $result && $path == $this->cwd() || + $this->cwd() != $cwd ) { @ftp_chdir($this->link, $cwd); return true; } @@ -425,9 +452,9 @@ class WP_Filesystem_FTPext{ } else { $limitFile = false; } - //if( ! $this->is_dir($path) ) - // return false; - $list = ftp_rawlist($this->link , '-a ' . $path, false); + + $list = @ftp_rawlist($this->link , '-a ' . $path, false); + if ( $list === false ) return false; diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 15ab390..5365623 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -86,49 +86,67 @@ class WP_Filesystem_ftpsockets{ $this->permission = $perm; } - function find_base_dir($base = '.',$echo = false) { + function find_base_dir($base = '.',$echo = false, $loop = false) { + //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) $abspath = $mat[1]; } + //Set up the base directory (Which unless specified, is the current one) if( empty( $base ) || '.' == $base ) $base = $this->cwd(); - if( empty( $base ) ) $base = '/'; - if( '/' != substr($base, -1) ) $base .= '/'; - - if($echo) echo __('Changing to ') . $base .'<br>'; - if( false === $this->chdir($base) ) - return false; - - if( $this->exists($base . 'wp-settings.php') ){ - if($echo) echo __('Found ') . $base . 'wp-settings.php<br>'; - $this->wp_base = $base; - return $this->wp_base; + $base = trailingslashit($base); + + //Can we see the Current directory as part of the ABSPATH? + $location = strpos($abspath, $base); + if( false !== $location ) { + $newbase = path_join($base, substr($abspath, $location + strlen($base))); + + if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly. + if($echo) printf( __('Changing to %s') . '<br/>', $newbase ); + //Check to see if it exists in that folder. + if( $this->exists($newbase . 'wp-settings.php') ){ + if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php<br/>' ); + return $newbase; + } + } } - - if( strpos($abspath, $base) > 0) - $arrPath = split('/',substr($abspath,strpos($abspath, $base))); - else - $arrPath = split('/',$abspath); - - for($i = 0; $i <= count($arrPath); $i++) - if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] ); - - foreach($arrPath as $key=>$folder){ - if( $this->is_dir($base . $folder) ){ - if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/<br>'; - return $this->find_base_dir($base . $folder . '/',$echo); + + //Ok, Couldnt do a magic location from that particular folder level + + //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. + $files = $this->dirlist($base); + + $arrPath = explode('/', $abspath); + foreach($arrPath as $key){ + //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, + // If its found, change into it and follow through looking for it. + // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on. + // If it reaches the end, and still cant find it, it'll return false for the entire function. + if( isset($files[ $key ]) ){ + //Lets try that folder: + $folder = path_join($base, $key); + if($echo) printf( __('Changing to %s') . '<br/>', $folder ); + $ret = $this->find_base_dir( $folder, $echo, $loop); + if( $ret ) + return $ret; } } - - if( $base == '/' ) - return false; - //If we get this far, somethings gone wrong, change to / and restart the process. - return $this->find_base_dir('/',$echo); + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ 'wp-settings.php' ]) ){ + if($echo) printf( __('Found %s'), $base . 'wp-settings.php<br/>' ); + return $base; + } + if( $loop ) + return false;//Prevent tihs function looping again. + //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups. + return $this->find_base_dir('/', $echo, true); } function get_base_dir($base = '.', $echo = false){ + if( defined('FTP_BASE') ) + $this->wp_base = FTP_BASE; if( empty($this->wp_base) ) $this->wp_base = $this->find_base_dir($base, $echo); return $this->wp_base; @@ -144,6 +162,8 @@ class WP_Filesystem_ftpsockets{ } $this->ftp->SetType($type); $temp = tmpfile(); + if ( ! $temp ) + return false; if ( ! $this->ftp->fget($temp, $file) ) { fclose($temp); return ''; //Blank document, File does exist, Its just blank. @@ -168,6 +188,8 @@ class WP_Filesystem_ftpsockets{ $this->ftp->SetType($type); $temp = tmpfile(); + if ( ! $temp ) + return false; fwrite($temp,$contents); fseek($temp, 0); //Skip back to the start of the file being written to $ret = $this->ftp->fput($file, $temp); @@ -176,7 +198,10 @@ class WP_Filesystem_ftpsockets{ } function cwd(){ - return $this->ftp->pwd(); + $cwd = $this->ftp->pwd(); + if( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; } function chdir($file){ @@ -388,8 +413,7 @@ class WP_Filesystem_ftpsockets{ } else { $limitFile = false; } - //if( ! $this->is_dir($path) ) - // return false; + $list = $this->ftp->dirlist($path); if( ! $list ) return false; diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php index ae0d1d9..e08ae4d 100644 --- a/wp-admin/includes/comment.php +++ b/wp-admin/includes/comment.php @@ -8,9 +8,7 @@ function comment_exists($comment_author, $comment_date) { } function edit_comment() { - global $user_ID; - $comment_ID = (int) $_POST['comment_ID']; $comment_post_ID = (int) $_POST['comment_post_ID']; if (!current_user_can( 'edit_post', $comment_post_ID )) @@ -23,6 +21,14 @@ function edit_comment() { $_POST['comment_content'] = $_POST['content']; $_POST['comment_ID'] = (int) $_POST['comment_ID']; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -65,4 +71,26 @@ function get_pending_comments_num( $post_id ) { return $pending; } -?>
\ No newline at end of file +// Add avatars to relevant places in admin, or try to + +function floated_admin_avatar( $name ) { + global $comment; + + $id = $avatar = false; + if ( $comment->comment_author_email ) + $id = $comment->comment_author_email; + if ( $comment->user_id ) + $id = $comment->user_id; + + if ( $id ) + $avatar = get_avatar( $id, 32 ); + + return "$avatar $name"; +} + +if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { + if ( get_option('show_avatars') ) + add_filter( 'comment_author', 'floated_admin_avatar' ); +} + +?> diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index c675c4d..72a6dbc 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -24,7 +24,7 @@ function wp_dashboard_setup() { // Recent Comments Widget if ( current_user_can( 'moderate_comments' ) && $mod_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'") ) { $notice = sprintf( __ngettext( '%d comment awaiting moderation', '%d comments awaiting moderation', $mod_comments ), $mod_comments ); - $notice = "<a href='moderation.php'>$notice</a>"; + $notice = "<a href='edit-comments.php?comment_status=moderated'>$notice</a>"; } else { $notice = ''; } @@ -62,8 +62,8 @@ function wp_dashboard_setup() { if ( !isset( $widget_options['dashboard_primary'] ) ) { $update = true; $widget_options['dashboard_primary'] = array( - 'link' => apply_filters( 'dashboard_primary_link', 'http://wordpress.org/development/' ), - 'url' => apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ), + 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/development/' ) ), + 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/development/feed/' ) ), 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Development Blog' ) ), 'items' => 2, 'show_summary' => 1, @@ -84,8 +84,8 @@ function wp_dashboard_setup() { if ( !isset( $widget_options['dashboard_secondary'] ) ) { $update = true; $widget_options['dashboard_secondary'] = array( - 'link' => apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ), - 'url' => apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' ), + 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), 'items' => 15 ); @@ -144,7 +144,7 @@ function wp_dashboard_setup() { if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { ob_start(); // hack - but the same hack wp-admin/widgets.php uses - wp_dashbaord_trigger_widget_control( $_POST['widget_id'] ); + wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); ob_end_clean(); wp_redirect( remove_query_arg( 'edit' ) ); exit; @@ -212,7 +212,7 @@ function wp_dashboard_dynamic_sidebar_params( $params ) { $content_class .= ' dashboard-widget-control'; $wp_registered_widgets[$widget_id]['callback'] = 'wp_dashboard_empty'; $sidebar_widget_name = $wp_registered_widget_controls[$widget_id]['name']; - $params[1] = 'wp_dashbaord_trigger_widget_control'; + $params[1] = 'wp_dashboard_trigger_widget_control'; $sidebar_before_widget .= '<form action="' . remove_query_arg( 'edit' ) . '" method="post">'; $sidebar_after_widget = "<div class='dashboard-widget-submit'><input type='hidden' name='sidebar' value='wp_dashboard' /><input type='hidden' name='widget_id' value='$widget_id' /><input type='submit' value='" . __( 'Save' ) . "' /></div></form>$sidebar_after_widget"; $links[] = '<a href="' . remove_query_arg( 'edit' ) . '">' . __( 'Cancel' ) . '</a>'; @@ -284,21 +284,23 @@ function wp_dashboard_recent_comments( $sidebar_args ) { ?> <blockquote><p>“<?php comment_excerpt(); ?>”</p></blockquote> <p class='comment-meta'><?php echo $comment_meta; ?></p> - +<?php + if ( $comments_query->comment_count > 1 ) : ?> <ul id="dashboard-comments-list"> <?php - else : + endif; // comment_count + else : // is_first ?> <li class='comment-meta'><?php echo $comment_meta; ?></li> <?php - endif; + endif; // is_first } -?> + if ( $comments_query->comment_count > 1 ) : ?> </ul> - <?php + endif; // comment_count; } @@ -361,7 +363,7 @@ function wp_dashboard_incoming_links_output() { echo "</ul>\n"; } else { - echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. They have found no incoming links found… yet. It’s okay — there is no rush.') . "</p>\n"; + echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "</p>\n"; } } @@ -499,7 +501,7 @@ function wp_dashboard_empty( $sidebar_args, $callback = false ) { /* Dashboard Widgets Controls. Ssee also wp_dashboard_empty() */ // Calls widget_control callback -function wp_dashbaord_trigger_widget_control( $widget_control_id = false ) { +function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { global $wp_registered_widget_controls; if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) ) call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] ); diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php index a712177..5590826 100644 --- a/wp-admin/includes/export.php +++ b/wp-admin/includes/export.php @@ -195,12 +195,12 @@ echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n"; <title><?php echo apply_filters('the_title_rss', $post->post_title); ?></title> <link><?php the_permalink_rss() ?></link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> -<dc:creator><?php the_author() ?></dc:creator> +<dc:creator><?php echo wxr_cdata(get_the_author()); ?></dc:creator> <?php wxr_post_taxonomy() ?> <guid isPermaLink="false"><?php the_guid(); ?></guid> <description></description> -<content:encoded><![CDATA[<?php echo apply_filters('the_content_export', $post->post_content); ?>]]></content:encoded> +<content:encoded><?php echo wxr_cdata( apply_filters('the_content_export', $post->post_content) ); ?></content:encoded> <wp:post_id><?php echo $post->ID; ?></wp:post_id> <wp:post_date><?php echo $post->post_date; ?></wp:post_date> <wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt> @@ -238,7 +238,7 @@ if ( $comments ) { foreach ( $comments as $c ) { ?> <wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP> <wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date> <wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt> -<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content> +<wp:comment_content><?php echo wxr_cdata($c->comment_content) ?></wp:comment_content> <wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved> <wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type> <wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent> @@ -252,4 +252,4 @@ if ( $comments ) { foreach ( $comments as $c ) { ?> <?php } -?>
\ No newline at end of file +?> diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 45c05e5..75ef4e3 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -1,6 +1,6 @@ <?php -$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ), +$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'rtl.css' => __( 'RTL Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'searchform.php' => __( 'Search Form' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'link.php' => __( 'Links Template' ), 'functions.php' => __( 'Theme Functions' ), 'attachment.php' => __( 'Attachment Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ), // Deprecated files 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' )); function get_file_description( $file ) { @@ -42,6 +42,20 @@ function get_real_file_to_edit( $file ) { return $real_file; } +function get_temp_dir() { + if ( defined('WP_TEMP_DIR') ) + return trailingslashit(WP_TEMP_DIR); + + $temp = ABSPATH . 'wp-content/'; + if ( is_dir($temp) && is_writable($temp) ) + return $temp; + + if ( function_exists('sys_get_temp_dir') ) + return trailingslashit(sys_get_temp_dir()); + + return '/tmp/'; +} + function validate_file( $file, $allowed_files = '' ) { if ( false !== strpos( $file, '..' )) return 1; @@ -114,6 +128,7 @@ function wp_handle_upload( &$file, $overrides = false ) { // If you override this, you must provide $ext and $type!!!! $test_type = true; + $mimes = false; // Install user overrides. Did we mention that this voids your warranty? if ( is_array( $overrides ) ) @@ -146,32 +161,16 @@ function wp_handle_upload( &$file, $overrides = false ) { if ( !$ext ) $ext = ltrim(strrchr($file['name'], '.'), '.'); + + if ( !$type ) + $type = $file['type']; } // A writable uploads dir will pass this test. Again, there's no point overriding this one. if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) return $upload_error_handler( $file, $uploads['error'] ); - // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. - if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) { - $filename = $unique_filename_callback( $uploads['path'], $file['name'] ); - } else { - $number = ''; - $filename = str_replace( '#', '_', $file['name'] ); - $filename = str_replace( array( '\\', "'" ), '', $filename ); - if ( empty( $ext) ) - $ext = ''; - else - $ext = ".$ext"; - while ( file_exists( $uploads['path'] . "/$filename" ) ) { - if ( '' == "$number$ext" ) - $filename = $filename . ++$number . $ext; - else - $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); - } - $filename = str_replace( $ext, '', $filename ); - $filename = sanitize_title_with_dashes( $filename ) . $ext; - } + $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); // Move the file to the uploads dir $new_file = $uploads['path'] . "/$filename"; @@ -191,4 +190,148 @@ function wp_handle_upload( &$file, $overrides = false ) { return $return; } +/** +* Downloads a url to a local file using the Snoopy HTTP Class +* +* @param string $url the URL of the file to download +* @return mixed WP_Error on failure, string Filename on success. +*/ +function download_url( $url ) { + //WARNING: The file is not automatically deleted, The script must unlink() the file. + if( ! $url ) + return new WP_Error('http_no_url', __('Invalid URL Provided')); + + $tmpfname = tempnam(get_temp_dir(), 'wpupdate'); + if( ! $tmpfname ) + return new WP_Error('http_no_file', __('Could not create Temporary file')); + + $handle = @fopen($tmpfname, 'w'); + if( ! $handle ) + return new WP_Error('http_no_file', __('Could not create Temporary file')); + + require_once( ABSPATH . 'wp-includes/class-snoopy.php' ); + $snoopy = new Snoopy(); + $snoopy->fetch($url); + + if( $snoopy->status != '200' ){ + fclose($handle); + unlink($tmpfname); + return new WP_Error('http_404', trim($snoopy->response_code)); + } + fwrite($handle, $snoopy->results); + fclose($handle); + + return $tmpfname; +} + +function unzip_file($file, $to) { + global $wp_filesystem; + + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + $fs =& $wp_filesystem; + + require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); + + $archive = new PclZip($file); + + // Is the archive valid? + if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) ) + return new WP_Error('incompatible_archive', __('Incompatible archive'), $archive->errorInfo(true)); + + if ( 0 == count($archive_files) ) + return new WP_Error('empty_archive', __('Empty archive')); + + $to = trailingslashit($to); + $path = explode('/', $to); + $tmppath = ''; + for ( $j = 0; $j < count($path) - 1; $j++ ) { + $tmppath .= $path[$j] . '/'; + if ( ! $fs->is_dir($tmppath) ) + $fs->mkdir($tmppath, 0755); + } + + foreach ($archive_files as $file) { + $path = explode('/', $file['filename']); + $tmppath = ''; + + // Loop through each of the items and check that the folder exists. + for ( $j = 0; $j < count($path) - 1; $j++ ) { + $tmppath .= $path[$j] . '/'; + if ( ! $fs->is_dir($to . $tmppath) ) + if ( !$fs->mkdir($to . $tmppath, 0755) ) + return new WP_Error('mkdir_failed', __('Could not create directory')); + } + + // We've made sure the folders are there, so let's extract the file now: + if ( ! $file['folder'] ) + if ( !$fs->put_contents( $to . $file['filename'], $file['content']) ) + return new WP_Error('copy_failed', __('Could not copy file')); + $fs->chmod($to . $file['filename'], 0644); + } + + return true; +} + +function copy_dir($from, $to) { + global $wp_filesystem; + + $dirlist = $wp_filesystem->dirlist($from); + + $from = trailingslashit($from); + $to = trailingslashit($to); + + foreach ( (array) $dirlist as $filename => $fileinfo ) { + if ( 'f' == $fileinfo['type'] ) { + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) + return false; + $wp_filesystem->chmod($to . $filename, 0644); + } elseif ( 'd' == $fileinfo['type'] ) { + if ( !$wp_filesystem->mkdir($to . $filename, 0755) ) + return false; + if ( !copy_dir($from . $filename, $to . $filename) ) + return false; + } + } + + return true; +} + +function WP_Filesystem( $args = false, $preference = false ) { + global $wp_filesystem; + + $method = get_filesystem_method($preference); + if ( ! $method ) + return false; + + require_once('class-wp-filesystem-'.$method.'.php'); + $method = "WP_Filesystem_$method"; + + $wp_filesystem = new $method($args); + + if ( $wp_filesystem->errors->get_error_code() ) + return false; + + if ( !$wp_filesystem->connect() ) + return false; //There was an erorr connecting to the server. + + return true; +} + +function get_filesystem_method() { + $tempFile = tempnam(get_temp_dir(), 'WPU'); + + if ( getmyuid() == fileowner($tempFile) ) { + unlink($tempFile); + return 'direct'; + } else { + unlink($tempFile); + } + + if ( extension_loaded('ftp') ) return 'ftpext'; + if ( extension_loaded('sockets') || function_exists('fsockopen') ) return 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread + return false; +} + ?> diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index ec4466e..2af026d 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -1,110 +1,46 @@ <?php - -function get_udims( $width, $height) { - if ( $height <= 96 && $width <= 128 ) - return array( $width, $height); - elseif ( $width / $height > 4 / 3 ) - return array( 128, (int) ($height / $width * 128 )); - else - return array( (int) ($width / $height * 96 ), 96 ); -} - -function wp_create_thumbnail( $file, $max_side, $effect = '' ) { - - // 1 = GIF, 2 = JPEG, 3 = PNG - - if ( file_exists( $file ) ) { - $type = getimagesize( $file ); - - // if the associated function doesn't exist - then it's not - // handle. duh. i hope. - - if (!function_exists( 'imagegif' ) && $type[2] == 1 ) { - $error = __( 'Filetype not supported. Thumbnail not created.' ); - } - elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) { - $error = __( 'Filetype not supported. Thumbnail not created.' ); - } - elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) { - $error = __( 'Filetype not supported. Thumbnail not created.' ); - } else { - - // create the initial copy from the original file - if ( $type[2] == 1 ) { - $image = imagecreatefromgif( $file ); - } - elseif ( $type[2] == 2 ) { - $image = imagecreatefromjpeg( $file ); - } - elseif ( $type[2] == 3 ) { - $image = imagecreatefrompng( $file ); - } - - if ( function_exists( 'imageantialias' )) - imageantialias( $image, TRUE ); - - $image_attr = getimagesize( $file ); - - // figure out the longest side - - if ( $image_attr[0] > $image_attr[1] ) { - $image_width = $image_attr[0]; - $image_height = $image_attr[1]; - $image_new_width = $max_side; - - $image_ratio = $image_width / $image_new_width; - $image_new_height = $image_height / $image_ratio; - //width is > height - } else { - $image_width = $image_attr[0]; - $image_height = $image_attr[1]; - $image_new_height = $max_side; - - $image_ratio = $image_height / $image_new_height; - $image_new_width = $image_width / $image_ratio; - //height > width - } - - $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height); - @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] ); - - // If no filters change the filename, we'll do a default transformation. - if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) ) - $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 ); - - $thumbpath = str_replace( basename( $file ), $thumb, $file ); - - // move the thumbnail to its final destination - if ( $type[2] == 1 ) { - if (!imagegif( $thumbnail, $thumbpath ) ) { - $error = __( "Thumbnail path invalid" ); - } - } - elseif ( $type[2] == 2 ) { - if (!imagejpeg( $thumbnail, $thumbpath ) ) { - $error = __( "Thumbnail path invalid" ); - } - } - elseif ( $type[2] == 3 ) { - if (!imagepng( $thumbnail, $thumbpath ) ) { - $error = __( "Thumbnail path invalid" ); - } - } - - } - } else { - $error = __( 'File not found' ); - } - - if (!empty ( $error ) ) { - return $error; - } else { - return apply_filters( 'wp_create_thumbnail', $thumbpath ); - } +/** + * File contains all the administration image manipulation functions. + * + * @package WordPress + */ + +/** + * wp_create_thumbnail() - Create a thumbnail from an Image given a maximum side size. + * + * @package WordPress + * @param mixed $file Filename of the original image, Or attachment id + * @param int $max_side Maximum length of a single side for the thumbnail + * @return string Thumbnail path on success, Error string on failure + * + * This function can handle most image file formats which PHP supports. + * If PHP does not have the functionality to save in a file of the same format, the thumbnail will be created as a jpeg. + */ +function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) { + + $thumbpath = image_resize( $file, $max_side, $max_side ); + return apply_filters( 'wp_create_thumbnail', $thumbpath ); } +/** + * wp_crop_image() - Crop an Image to a given size. + * + * @package WordPress + * @internal Missing Long Description + * @param int $src_file The source file + * @param int $src_x The start x position to crop from + * @param int $src_y The start y position to crop from + * @param int $src_w The width to crop + * @param int $src_h The height to crop + * @param int $dst_w The destination width + * @param int $dst_h The destination height + * @param int $src_abs If the source crop points are absolute + * @param int $dst_file The destination file to write to + * @return string New filepath on success, String error message on failure + * + */ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { - if ( ctype_digit( $src_file ) ) // Handle int as attachment ID + if ( is_numeric( $src_file ) ) // Handle int as attachment ID $src_file = get_attached_file( $src_file ); $src = wp_load_image( $src_file ); @@ -124,8 +60,10 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_ imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); - if ( !$dst_file ) - $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file ); + imagedestroy( $src ); // Free up memory + + if ( ! $dst_file ) + $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file ); $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); @@ -135,44 +73,69 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_ return false; } +/** + * wp_generate_attachment_metadata() - Generate post Image attachment Metadata + * + * @package WordPress + * @internal Missing Long Description + * @param int $attachment_id Attachment Id to process + * @param string $file Filepath of the Attached image + * @return mixed Metadata for attachment + * + */ function wp_generate_attachment_metadata( $attachment_id, $file ) { $attachment = get_post( $attachment_id ); $metadata = array(); - if ( preg_match('!^image/!', get_post_mime_type( $attachment )) ) { - $imagesize = getimagesize($file); - $metadata['width'] = $imagesize['0']; - $metadata['height'] = $imagesize['1']; - list($uwidth, $uheight) = get_udims($metadata['width'], $metadata['height']); + if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) { + $imagesize = getimagesize( $file ); + $metadata['width'] = $imagesize[0]; + $metadata['height'] = $imagesize[1]; + list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']); $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'"; $metadata['file'] = $file; - $max = apply_filters( 'wp_thumbnail_creation_size_limit', 3 * 1024 * 1024, $attachment_id, $file ); - - if ( $max < 0 || $metadata['width'] * $metadata['height'] < $max ) { - $max_side = apply_filters( 'wp_thumbnail_max_side_length', 128, $attachment_id, $file ); - $thumb = wp_create_thumbnail( $file, $max_side ); - - if ( @file_exists($thumb) ) - $metadata['thumb'] = basename($thumb); + // make thumbnails and other intermediate sizes + $sizes = array('thumbnail', 'medium'); + $sizes = apply_filters('intermediate_image_sizes', $sizes); + + foreach ($sizes as $size) { + $resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") ); + if ( $resized ) + $metadata['sizes'][$size] = $resized; } + + // fetch additional metadata from exif/iptc + $image_meta = wp_read_image_metadata( $file ); + if ($image_meta) + $metadata['image_meta'] = $image_meta; + } return apply_filters( 'wp_generate_attachment_metadata', $metadata ); } +/** + * wp_load_image() - Load an image which PHP Supports. + * + * @package WordPress + * @internal Missing Long Description + * @param string $file Filename of the image to load + * @return resource The resulting image resource on success, Error string on failure. + * + */ function wp_load_image( $file ) { - if ( ctype_digit( $file ) ) + if ( is_numeric( $file ) ) $file = get_attached_file( $file ); - if ( !file_exists( $file ) ) + if ( ! file_exists( $file ) ) return sprintf(__("File '%s' doesn't exist?"), $file); if ( ! function_exists('imagecreatefromstring') ) return __('The GD image library is not installed.'); - $contents = file_get_contents( $file ); - - $image = imagecreatefromstring( $contents ); + // Set artificially high because GD uses uncompressed images in memory + @ini_set('memory_limit', '256M'); + $image = imagecreatefromstring( file_get_contents( $file ) ); if ( !is_resource( $image ) ) return sprintf(__("File '%s' is not an image."), $file); @@ -180,13 +143,140 @@ function wp_load_image( $file ) { return $image; } +/** + * get_udims() - Calculated the new dimentions for downsampled images + * + * @package WordPress + * @internal Missing Description + * @see wp_shrink_dimensions() + * @param int $width Current width of the image + * @param int $height Current height of the image + * @return mixed Array(height,width) of shrunk dimensions. + * + */ +function get_udims( $width, $height) { + return wp_shrink_dimensions( $width, $height ); +} +/** + * wp_shrink_dimensions() - Calculates the new dimentions for a downsampled image. + * + * @package WordPress + * @internal Missing Long Description + * @param int $width Current width of the image + * @param int $height Current height of the image + * @param int $wmax Maximum wanted width + * @param int $hmax Maximum wanted height + * @return mixed Array(height,width) of shrunk dimensions. + * + */ function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) { - if ( $height <= $hmax && $width <= $wmax ) - return array( $width, $height); - elseif ( $width / $height > $wmax / $hmax ) - return array( $wmax, (int) ($height / $width * $wmax )); + return wp_constrain_dimensions( $width, $height, $wmax, $hmax ); +} + +// convert a fraction string to a decimal +function wp_exif_frac2dec($str) { + @list( $n, $d ) = explode( '/', $str ); + if ( !empty($d) ) + return $n / $d; + return $str; +} + +// convert the exif date format to a unix timestamp +function wp_exif_date2ts($str) { + // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'? + @list( $date, $time ) = explode( ' ', trim($str) ); + @list( $y, $m, $d ) = explode( ':', $date ); + + return strtotime( "{$y}-{$m}-{$d} {$time}" ); +} + +// get extended image metadata, exif or iptc as available +function wp_read_image_metadata( $file ) { + if ( !file_exists( $file ) ) + return false; + + list(,,$sourceImageType) = getimagesize( $file ); + + // exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use. + // We'll normalize it and just extract the fields that are likely to be useful. Fractions and numbers + // are converted to floats, dates to unix timestamps, and everything else to strings. + $meta = array( + 'aperture' => 0, + 'credit' => '', + 'camera' => '', + 'caption' => '', + 'created_timestamp' => 0, + 'copyright' => '', + 'focal_length' => 0, + 'iso' => 0, + 'shutter_speed' => 0, + 'title' => '', + ); + + // read iptc first, since it might contain data not available in exif such as caption, description etc + if ( is_callable('iptcparse') ) { + getimagesize($file, $info); + if ( !empty($info['APP13']) ) { + $iptc = iptcparse($info['APP13']); + if ( !empty($iptc['2#110'][0]) ) // credit + $meta['credit'] = trim( $iptc['2#110'][0] ); + elseif ( !empty($iptc['2#080'][0]) ) // byline + $meta['credit'] = trim( $iptc['2#080'][0] ); + if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created datee and time + $meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]); + if ( !empty($iptc['2#120'][0]) ) // caption + $meta['caption'] = trim( $iptc['2#120'][0] ); + if ( !empty($iptc['2#116'][0]) ) // copyright + $meta['copyright'] = trim( $iptc['2#116'][0] ); + if ( !empty($iptc['2#005'][0]) ) // title + $meta['title'] = trim( $iptc['2#005'][0] ); + } + } + + // fetch additional info from exif if available + if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) { + $exif = exif_read_data( $file ); + if (!empty($exif['FNumber'])) + $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); + if (!empty($exif['Model'])) + $meta['camera'] = trim( $exif['Model'] ); + if (!empty($exif['DateTimeDigitized'])) + $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']); + if (!empty($exif['FocalLength'])) + $meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] ); + if (!empty($exif['ISOSpeedRatings'])) + $meta['iso'] = $exif['ISOSpeedRatings']; + if (!empty($exif['ExposureTime'])) + $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] ); + } + // FIXME: try other exif libraries if available + + return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType ); + +} + +// is the file a real image file? +function file_is_valid_image($path) { + $size = @getimagesize($path); + return !empty($size); +} + +// is the file an image suitable for displaying within a web page? +function file_is_displayable_image($path) { + $info = @getimagesize($path); + if ( empty($info) ) + $result = false; + elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) + // only gif, jpeg and png images can reliably be displayed + $result = false; + elseif ( $info['channels'] > 0 && $info['channels'] != 3 ) { + // some web browsers can't display cmyk or grayscale jpegs + $result = false; + } else - return array( (int) ($width / $height * $hmax ), $hmax ); + $result = true; + + return apply_filters('file_is_displayable_image', $result, $path); } ?> diff --git a/wp-admin/includes/import.php b/wp-admin/includes/import.php index 9835bb1..35fd141 100644 --- a/wp-admin/includes/import.php +++ b/wp-admin/includes/import.php @@ -2,7 +2,8 @@ function get_importers() { global $wp_importers; - uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); + if ( is_array($wp_importers) ) + uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); return $wp_importers; } @@ -19,6 +20,7 @@ function wp_import_cleanup( $id ) { function wp_import_handle_upload() { $overrides = array( 'test_form' => false, 'test_type' => false ); + $_FILES['import']['name'] .= '.import'; $file = wp_handle_upload( $_FILES['import'], $overrides ); if ( isset( $file['error'] ) ) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index b43c2da..5803e3f 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -50,7 +50,7 @@ function the_media_upload_tabs() { function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { - $html = get_image_tag($id, $alt, $title, $align, $rel, $size); + $html = get_image_tag($id, $alt, $title, $align, $size); $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; @@ -124,7 +124,7 @@ function wp_iframe($content_func /* ... */) { <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> <head> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> -<title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — WordPress</title> +<title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?></title> <?php wp_admin_css( 'css/global' ); wp_admin_css(); @@ -203,7 +203,7 @@ function media_upload_form_handler() { check_admin_referer('media-form'); // Insert media button was clicked - if ( !empty($_FILES) ) { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); @@ -246,8 +246,11 @@ function media_upload_form_handler() { $send_id = (int) array_shift($keys); $attachment = $_POST['attachments'][$send_id]; $html = $attachment['post_title']; - if ( !empty($attachment['url']) ) - $html = "<a href='{$attachment['url']}'>$html</a>"; + if ( !empty($attachment['url']) ) { + if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) ) + $rel = " rel='attachment wp-att-".attribute_escape($send_id)."'"; + $html = "<a href='{$attachment['url']}'$rel>$html</a>"; + } $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); return media_send_to_editor($html); } @@ -256,7 +259,7 @@ function media_upload_form_handler() { } function media_upload_image() { - if ( !empty($_FILES) ) { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -268,14 +271,15 @@ function media_upload_image() { if ( !empty($_POST['insertonlybutton']) ) { $src = $_POST['insertonly']['src']; - if ( !strpos($src, '://') ) + if ( !empty($src) && !strpos($src, '://') ) $src = "http://$src"; $alt = attribute_escape($_POST['insertonly']['alt']); if ( isset($_POST['insertonly']['align']) ) { $align = attribute_escape($_POST['insertonly']['align']); $class = " class='align$align'"; } - $html = "<img src='$src' alt='$alt'$class />"; + if ( !empty($src) ) + $html = "<img src='$src' alt='$alt'$class />"; return media_send_to_editor($html); } @@ -288,11 +292,14 @@ function media_upload_image() { $errors = $return; } + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); } function media_upload_audio() { - if ( !empty($_FILES) ) { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -304,10 +311,13 @@ function media_upload_audio() { if ( !empty($_POST['insertonlybutton']) ) { $href = $_POST['insertonly']['href']; - if ( !strpos($href, '://') ) + if ( !empty($href) && !strpos($href, '://') ) $href = "http://$href"; $title = attribute_escape($_POST['insertonly']['title']); - $html = "<a href='$href' >$title</a>"; + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "<a href='$href' >$title</a>"; return media_send_to_editor($html); } @@ -320,11 +330,14 @@ function media_upload_audio() { $errors = $return; } + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); } function media_upload_video() { - if ( !empty($_FILES) ) { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -336,10 +349,13 @@ function media_upload_video() { if ( !empty($_POST['insertonlybutton']) ) { $href = $_POST['insertonly']['href']; - if ( !strpos($href, '://') ) + if ( !empty($href) && !strpos($href, '://') ) $href = "http://$href"; $title = attribute_escape($_POST['insertonly']['title']); - $html = "<a href='$href' >$title</a>"; + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "<a href='$href' >$title</a>"; return media_send_to_editor($html); } @@ -352,11 +368,14 @@ function media_upload_video() { $errors = $return; } + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); } function media_upload_file() { - if ( !empty($_FILES) ) { + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -368,10 +387,13 @@ function media_upload_file() { if ( !empty($_POST['insertonlybutton']) ) { $href = $_POST['insertonly']['href']; - if ( !strpos($href, '://') ) + if ( !empty($href) && !strpos($href, '://') ) $href = "http://$href"; $title = attribute_escape($_POST['insertonly']['title']); - $html = "<a href='$href' >$title</a>"; + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "<a href='$href' >$title</a>"; return media_send_to_editor($html); } @@ -384,6 +406,9 @@ function media_upload_file() { $errors = $return; } + if ( isset($_POST['save']) ) + $errors['upload_notice'] = __('Saved.'); + return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); } @@ -413,44 +438,13 @@ function media_upload_library() { return wp_iframe( 'media_upload_library_form', $errors ); } -function get_attachment_taxonomies($attachment) { - if ( is_int( $attachment ) ) - $attachment = get_post($attachment); - else if ( is_array($attachment) ) - $attachment = (object) $attachment; - - if ( ! is_object($attachment) ) - return array(); - - $filename = basename($attachment->guid); - - $objects = array('attachment'); - - if ( false !== strpos($filename, '.') ) - $objects[] = 'attachment:' . substr($filename, strrpos($filename, '.') + 1); - if ( !empty($attachment->post_mime_type) ) { - $objects[] = 'attachment:' . $attachment->post_mime_type; - if ( false !== strpos($attachment->post_mime_type, '/') ) - foreach ( explode('/', $attachment->post_mime_type) as $token ) - if ( !empty($token) ) - $objects[] = "attachment:$token"; - } - - $taxonomies = array(); - foreach ( $objects as $object ) - if ( $taxes = get_object_taxonomies($object) ) - $taxonomies = array_merge($taxonomies, $taxes); - - return array_unique($taxonomies); -} - function image_attachment_fields_to_edit($form_fields, $post) { if ( substr($post->post_mime_type, 0, 5) == 'image' ) { $form_fields['post_title']['required'] = true; - $form_fields['post_excerpt']['label'] = __('Description'); + $form_fields['post_excerpt']['label'] = __('Caption'); $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"'); - $form_fields['post_content']['label'] = __('Long Description'); + $form_fields['post_content']['label'] = __('Description'); $thumb = wp_get_attachment_thumb_url($post->ID); @@ -458,7 +452,7 @@ function image_attachment_fields_to_edit($form_fields, $post) { 'label' => __('Alignment'), 'input' => 'html', 'html' => " - <input type='radio' name='attachments[$post->ID][align]' id='image-align-none-$post->ID' value='none' /> + <input type='radio' name='attachments[$post->ID][align]' id='image-align-none-$post->ID' value='none' checked='checked' /> <label for='image-align-none-$post->ID' class='align image-align-none-label'>" . __('None') . "</label> <input type='radio' name='attachments[$post->ID][align]' id='image-align-left-$post->ID' value='left' /> <label for='image-align-left-$post->ID' class='align image-align-left-label'>" . __('Left') . "</label> @@ -517,6 +511,8 @@ function image_media_send_to_editor($html, $attachment_id, $attachment) { else $size = 'medium'; + $rel = ( $url == get_attachment_link($attachment_id) ); + return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); } @@ -541,11 +537,11 @@ function get_attachment_fields_to_edit($post, $errors = null) { 'value' => $edit_post->post_title, ), 'post_excerpt' => array( - 'label' => __('Description'), + 'label' => __('Caption'), 'value' => $edit_post->post_excerpt, ), 'post_content' => array( - 'label' => __('Long description'), + 'label' => __('Description'), 'value' => $edit_post->post_content, 'input' => 'textarea', ), @@ -662,10 +658,12 @@ function get_media_item( $attachment_id, $args = null ) { $toggle_links = ''; } + $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case + $item = " $type $toggle_links - <div class='filename new'>$filename</div> + <div class='filename new'>$display_title</div> <table class='slidetoggle describe $class'> <tbody class='media-item-info'> <tr> @@ -768,15 +766,27 @@ function media_upload_form( $errors = null ) { $flash_action_url = get_option('siteurl') . "/wp-admin/async-upload.php"; + // If Mac and mod_security, no Flash. :( + $flash = true; + if ( false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac') && apache_mod_loaded('mod_security') ) + $flash = false; + + $flash = apply_filters('flash_uploader', $flash); $post_id = intval($_REQUEST['post_id']); ?> <input type='hidden' name='post_id' value='<?php echo $post_id; ?>' /> +<div id="media-upload-notice"> +<?php if (isset($errors['upload_notice']) ) { ?> + <?php echo $errors['upload_notice']; ?> +<?php } ?> +</div> <div id="media-upload-error"> <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?> <?php echo $errors['upload_error']->get_error_message(); ?> <?php } ?> </div> +<?php if ( $flash ) : ?> <script type="text/javascript"> <!-- jQuery(function($){ @@ -794,7 +804,6 @@ jQuery(function($){ file_size_limit : "<?php echo wp_max_upload_size(); ?>b", swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available degraded_element_id : "html-upload-ui", // when swfupload is unavailable - swfupload_loaded_handler : uploadLoaded, file_dialog_start_handler : fileDialogStart, file_queued_handler : fileQueued, upload_start_handler : uploadStart, @@ -818,12 +827,17 @@ jQuery(function($){ <p><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p> </div> +<?php endif; // $flash ?> + <div id="html-upload-ui"> <p> - <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" value="<?php echo attribute_escape(__('Upload')); ?>" /> <a href="#" onClick="return top.tb_remove();"><?php _e('Cancel'); ?></a> + <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php echo attribute_escape(__('Upload')); ?>" /> <a href="#" onClick="return top.tb_remove();"><?php _e('Cancel'); ?></a> </p> <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> - <br style="clear:both" /> + <br class="clear" /> + <?php if ( is_lighttpd_before_150() ): ?> + <p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p> + <?php endif;?> </div> <?php } @@ -838,7 +852,7 @@ function media_upload_type_form($type = 'file', $errors = null, $id = null) { $callback = "type_form_$type"; ?> -<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form" id="<?php echo $type; ?>-form"> +<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form"> <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> <?php wp_nonce_field('media-form'); ?> <h3><?php _e('From Computer'); ?></h3> @@ -899,7 +913,7 @@ jQuery(function($){ --> </script> -<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="gallery-form"> +<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form"> <?php wp_nonce_field('media-form'); ?> <?php //media_upload_form( $errors ); ?> @@ -956,8 +970,14 @@ $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_po foreach ( $matches as $_type => $reals ) foreach ( $reals as $real ) $num_posts[$_type] += $_num_posts[$real]; -$class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; -$type_links[] = "<li><a href='" . remove_query_arg(array('post_mime_type', 'paged', 'm')) . "'$class>".__('All Types')."</a>"; +// If available type specified by media button clicked, filter by that type +if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { + $_GET['post_mime_type'] = $type; + list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); +} +if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) + $class = ' class="current"'; +$type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false)) . "'$class>".__('All Types')."</a>"; foreach ( $post_mime_types as $mime_type => $label ) { $class = ''; @@ -967,7 +987,7 @@ foreach ( $post_mime_types as $mime_type => $label ) { if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) $class = ' class="current"'; - $type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false)) . "'$class>" . sprintf($label[2], "<span id='$mime_type-counter'>{$num_posts[$mime_type]}</span>") . '</a>'; + $type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false)) . "'$class>" . sprintf(__ngettext($label[2][0], $label[2][1], $num_posts[$mime_type]), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>'; } echo implode(' | </li>', $type_links) . '</li>'; unset($type_links); @@ -989,7 +1009,7 @@ if ( $page_links ) echo "<div class='tablenav-pages'>$page_links</div>"; ?> -<div style="float: left"> +<div class="alignleft"> <?php $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; @@ -1024,11 +1044,11 @@ foreach ($arc_result as $arc_row) { </div> -<br style="clear:both;" /> +<br class="clear" /> </div> </form> -<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="library-form"> +<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="library-form"> <?php wp_nonce_field('media-form'); ?> <?php //media_upload_form( $errors ); ?> @@ -1067,7 +1087,7 @@ function type_form_image() { <tr> <th valign="top" scope="row" class="label"> <span class="alignleft"><label for="insertonly[alt]">' . __('Description') . '</label></span> - <span class="alignright"><abbr title="required">*</abbr></span> + <span class="alignright"><abbr title="required" class="required">*</abbr></span> </th> <td class="field"><input id="insertonly[alt]" name="insertonly[alt]" value="" type="text"></td> </tr> @@ -1075,13 +1095,13 @@ function type_form_image() { <tr class="align"> <th valign="top" scope="row" class="label"><label for="insertonly[align]">' . __('Alignment') . '</label></th> <td class="field"> - <input name="insertonly[align]" id="image-align-none-0" value="none" type="radio"> + <input name="insertonly[align]" id="image-align-none-0" value="none" type="radio" checked="checked" /> <label for="image-align-none-0" class="align image-align-none-label">' . __('None') . '</label> - <input name="insertonly[align]" id="image-align-left-0" value="left" type="radio"> + <input name="insertonly[align]" id="image-align-left-0" value="left" type="radio" /> <label for="image-align-left-0" class="align image-align-left-label">' . __('Left') . '</label> - <input name="insertonly[align]" id="image-align-center-0" value="center" type="radio"> + <input name="insertonly[align]" id="image-align-center-0" value="center" type="radio" /> <label for="image-align-center-0" class="align image-align-center-label">' . __('Center') . '</label> - <input name="insertonly[align]" id="image-align-right-0" value="right" type="radio"> + <input name="insertonly[align]" id="image-align-right-0" value="right" type="radio" /> <label for="image-align-right-0" class="align image-align-right-label">' . __('Right') . '</label> </td> </tr> @@ -1196,30 +1216,4 @@ add_action('admin_head_media_upload_gallery_form', 'media_admin_css'); add_filter('media_upload_library', 'media_upload_library'); add_action('admin_head_media_upload_library_form', 'media_admin_css'); - -// Any 'attachment' taxonomy will be included in the description input form for the multi uploader -// Example: -/* -register_taxonomy( - 'image_people', - 'attachment:image', - array( - 'label' => __('People'), - 'template' => __('People: %l'), - 'helps' => __('Left to right, top to bottom.'), - 'sort' => true, - 'args' => array( - 'orderby' => 'term_order' - ) - ) -); -*/ -/* -register_taxonomy('movie_director', 'attachment:video', array('label'=>__('Directors'), 'template'=>__('Directed by %l.'))); -register_taxonomy('movie_producer', 'attachment:video', array('label'=>__('Producers'), 'template'=>__('Produced by %l.'))); -register_taxonomy('movie_screenwriter', 'attachment:video', array('label'=>__('Screenwriter'), 'template'=>__('Screenplay by %l.'))); -register_taxonomy('movie_actor', 'attachment:video', array('label'=>__('Cast'), 'template'=>array(__('Cast: %l.'))); -register_taxonomy('movie_crew', 'attachment:video', array('label'=>__('Crew'), 'template'=>array(__('Crew: %l.'))); -*/ - ?> diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 23f998f..d38f308 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -1,18 +1,8 @@ <?php function got_mod_rewrite() { - global $is_apache; - - // take 3 educated guesses as to whether or not mod_rewrite is available - if ( !$is_apache ) - return false; - - if ( function_exists( 'apache_get_modules' ) ) { - if ( !in_array( 'mod_rewrite', apache_get_modules() ) ) - return false; - } - - return true; + $got_rewrite = apache_mod_loaded('mod_rewrite', true); + return apply_filters('got_rewrite', $got_rewrite); } // Returns an array of strings from a file (.htaccess ) from between BEGIN @@ -129,19 +119,15 @@ function update_recently_edited( $file ) { update_option( 'recently_edited', $oldfiles ); } -// If siteurl or home changed, reset cookies and flush rewrite rules. +// If siteurl or home changed, flush rewrite rules. function update_home_siteurl( $old_value, $value ) { - global $wp_rewrite, $user_login, $user_pass_md5; + global $wp_rewrite; if ( defined( "WP_INSTALLING" ) ) return; // If home changed, write rewrite rules to new location. $wp_rewrite->flush_rules(); - // Clear cookies for old paths. - wp_clearcookie(); - // Set cookies for new paths. - wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); } add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); @@ -174,62 +160,4 @@ function wp_reset_vars( $vars ) { } } } - -function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') { - global $new_whitelist_options, $sanitize_callbacks; - $new_whitelist_options[ $option_group ][] = $option_name; - if( $sanitize_callback != '' ) - add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); -} - -function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') { - global $new_whitelist_options, $sanitize_callbacks; - $pos = array_search( $option_name, $new_whitelist_options ); - if( $pos !== false ) - unset( $new_whitelist_options[ $option_group ][ $pos ] ); - if( $sanitize_callback != '' ) - remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); -} - -function option_update_filter( $options ) { - global $new_whitelist_options; - - if( is_array( $new_whitelist_options ) ) - $options = add_option_whitelist( $new_whitelist_options, $options ); - - return $options; -} -add_filter( 'whitelist_options', 'option_update_filter' ); - -function add_option_whitelist( $new_options, $options = '' ) { - if( $options == '' ) { - global $whitelist_options; - } else { - $whitelist_options = $options; - } - foreach( $new_options as $page => $keys ) { - foreach( $keys as $key ) { - $pos = array_search( $key, $whitelist_options[ $page ] ); - if( $pos === false ) - $whitelist_options[ $page ][] = $key; - } - } - return $whitelist_options; -} - -function remove_option_whitelist( $del_options, $options = '' ) { - if( $options == '' ) { - global $whitelist_options; - } else { - $whitelist_options = $options; - } - foreach( $del_options as $page => $keys ) { - foreach( $keys as $key ) { - $pos = array_search( $key, $whitelist_options[ $page ] ); - if( $pos !== false ) - unset( $whitelist_options[ $page ][ $pos ] ); - } - } - return $whitelist_options; -} ?> diff --git a/wp-admin/includes/mu.php b/wp-admin/includes/mu.php index a8a4344..7dc677f 100644 --- a/wp-admin/includes/mu.php +++ b/wp-admin/includes/mu.php @@ -382,13 +382,13 @@ function redirect_user_to_blog() { exit(); } } -add_action( 'admin_menu_permission', 'redirect_user_to_blog' ); +add_action( 'admin_page_access_denied', 'redirect_user_to_blog' ); function wpmu_menu() { global $menu, $submenu; if( is_site_admin() ) { - $menu[1] = array(__('Site Admin'), '10', 'wpmu-admin.php' ); + $menu[29] = array(__('Site Admin'), '10', 'wpmu-admin.php' ); $submenu[ 'wpmu-admin.php' ][1] = array( __('Admin'), '10', 'wpmu-admin.php' ); $submenu[ 'wpmu-admin.php' ][5] = array( __('Blogs'), '10', 'wpmu-blogs.php' ); $submenu[ 'wpmu-admin.php' ][10] = array( __('Users'), '10', 'wpmu-users.php' ); @@ -401,7 +401,7 @@ function wpmu_menu() { unset( $submenu['plugins.php'][10] ); unset( $submenu['options-general.php'][40] ); unset( $submenu['edit.php'][30] ); - unset( $menu['30'] ); + unset( $menu['35'] ); // Plugins $menu_perms = get_site_option( "menu_items" ); if( is_array( $menu_perms ) == false ) @@ -418,8 +418,6 @@ function mu_options( $options ) { $added = array( 'general' => array( 'new_admin_email', 'WPLANG', 'language' ) ); - unset( $options[ 'misc' ] ); - $options = remove_option_whitelist( $removed, $options ); $options = add_option_whitelist( $added, $options ); @@ -427,4 +425,170 @@ function mu_options( $options ) { } add_filter( 'whitelist_options', 'mu_options' ); +function import_no_new_users( $permission ) { + return false; +} +add_filter( 'import_allow_create_users', 'import_no_new_users' ); +// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too. + +function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') { + global $new_whitelist_options, $sanitize_callbacks; + $new_whitelist_options[ $option_group ][] = $option_name; + if( $sanitize_callback != '' ) + add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); +} + +function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') { + global $new_whitelist_options, $sanitize_callbacks; + $pos = array_search( $option_name, $new_whitelist_options ); + if( $pos !== false ) + unset( $new_whitelist_options[ $option_group ][ $pos ] ); + if( $sanitize_callback != '' ) + remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); +} + +function option_update_filter( $options ) { + global $new_whitelist_options; + + if( is_array( $new_whitelist_options ) ) + $options = add_option_whitelist( $new_whitelist_options, $options ); + + return $options; +} +add_filter( 'whitelist_options', 'option_update_filter' ); + +function add_option_whitelist( $new_options, $options = '' ) { + if( $options == '' ) { + global $whitelist_options; + } else { + $whitelist_options = $options; + } + foreach( $new_options as $page => $keys ) { + foreach( $keys as $key ) { + $pos = array_search( $key, $whitelist_options[ $page ] ); + if( $pos === false ) + $whitelist_options[ $page ][] = $key; + } + } + return $whitelist_options; +} + +function remove_option_whitelist( $del_options, $options = '' ) { + if( $options == '' ) { + global $whitelist_options; + } else { + $whitelist_options = $options; + } + foreach( $del_options as $page => $keys ) { + foreach( $keys as $key ) { + $pos = array_search( $key, $whitelist_options[ $page ] ); + if( $pos !== false ) + unset( $whitelist_options[ $page ][ $pos ] ); + } + } + return $whitelist_options; +} + +/* Blogswitcher */ +function blogswitch_init() { + global $current_user, $current_blog; + $blogs = get_blogs_of_user( $current_user->ID ); + if ( !$blogs ) + return; + add_action( 'admin_menu', 'blogswitch_ob_start' ); + add_action( 'dashmenu', 'blogswitch_markup' ); +} + + +function blogswitch_ob_start() { + wp_enqueue_script( 'blog-switch', '/wp-admin/js/blog-switch.js', array( 'jquery' ), 2 ); + ob_start( 'blogswitch_ob_content' ); +} + +function blogswitch_ob_content( $content ) { + $content = preg_replace( '#<ul id="dashmenu">.*?%%REAL_DASH_MENU%%#s', '<ul id="dashmenu">', $content ); + return str_replace( '%%END_REAL_DASH_MENU%%</ul>', '', $content ); +} + +function blogswitch_markup() { + global $current_user, $blog_id; // current blog + $list = array(); + $options = array(); + + + $primary_blog = get_usermeta( $current_user->ID, 'primary_blog' ); + + foreach ( $blogs = get_blogs_of_user( $current_user->ID ) as $blog ) { + if ( !$blog->blogname ) + continue; + + // Use siteurl for this in case of mapping + $parsed = parse_url( $blog->siteurl ); + $domain = $parsed['host']; + + if ( $_SERVER['HTTP_HOST'] === $domain ) { + $current = ' class="current"'; + $selected = ' selected="selected"'; + } else { + $current = ''; + $selected = ''; + } + + $url = clean_url( $blog->siteurl ) . '/wp-admin/'; + $name = wp_specialchars( strip_tags( $blog->blogname ) ); + $list_item = "<li><a href='$url'$current>$name</a></li>"; + $option_item = "<option value='$url'$selected>$name</option>"; + + if ( $blog_id == $blog->userblog_id ) { + $list[-2] = $list_item; + $options[] = $option_item; // [sic] don't reorder dropdown based on current blog + } elseif ( $primary_blog == $blog->userblog_id ) { + $list[-1] = $list_item; + $options[-1] = $option_item; + } else { + $list[] = $list_item; + $options[] = $option_item; + } + } + ksort($list); + ksort($options); + + $list = array_slice( $list, 0, 4 ); // First 4 + + $select = "\n\t\t<select>\n\t\t\t" . join( "\n\t\t\t", $options ) . "\n\t\t</select>"; + + echo "%%REAL_DASH_MENU%%\n\t" . join( "\n\t", $list ); + + if ( count($list) < count($options) ) : +?> + + <li id="all-my-blogs-tab" class="wp-no-js-hidden"><a href="#" class="blog-picker-toggle"><?php _e( 'All my blogs' ); ?></a></li> + + </ul> + + <form id="all-my-blogs" action="" method="get" style="display: none"> + <p> + <?php printf( __( 'Choose a blog: %s' ), $select ); ?> + + <input type="submit" class="button" value="<?php _e( 'Go' ); ?>" /> + <a href="#" class="blog-picker-toggle"><?php _e( 'Cancel' ); ?></a> + </p> + </form> + +<?php else : // counts ?> + + </ul> + +<?php + endif; // counts + + echo '%%END_REAL_DASH_MENU%%'; +} + +add_action( '_admin_menu', 'blogswitch_init' ); + +function mu_css() { + wp_admin_css( 'css/mu' ); +} +add_action( 'admin_head', 'mu_css' ); ?> diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index e5911bd..a862c51 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -31,7 +31,7 @@ function get_plugin_data( $plugin_file ) { return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version); } -function get_plugins() { +function get_plugins($plugin_folder = '') { global $wp_plugins; if ( isset( $wp_plugins ) ) { @@ -40,6 +40,8 @@ function get_plugins() { $wp_plugins = array (); $plugin_root = ABSPATH . PLUGINDIR; + if( !empty($plugin_folder) ) + $plugin_root .= $plugin_folder; // Files in wp-content/plugins directory $plugins_dir = @ opendir( $plugin_root); @@ -86,6 +88,117 @@ function get_plugins() { return $wp_plugins; } +function is_plugin_active($plugin){ + return in_array($plugin, get_option('active_plugins')); +} + +function activate_plugin($plugin, $redirect = '') { + $current = get_option('active_plugins'); + $plugin = trim($plugin); + + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + return $valid; + + if ( !in_array($plugin, $current) ) { + if ( !empty($redirect) ) + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error + ob_start(); + @include(ABSPATH . PLUGINDIR . '/' . $plugin); + $current[] = $plugin; + sort($current); + update_option('active_plugins', $current); + do_action('activate_' . $plugin); + ob_end_clean(); + } + + return null; +} + +function deactivate_plugins($plugins, $silent= false) { + $current = get_option('active_plugins'); + + if ( !is_array($plugins) ) + $plugins = array($plugins); + + foreach ( $plugins as $plugin ) { + if( ! is_plugin_active($plugin) ) + continue; + array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu! + if ( ! $silent ) //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. + do_action('deactivate_' . trim( $plugin )); + } + + update_option('active_plugins', $current); +} + +function deactivate_all_plugins() { + $current = get_option('active_plugins'); + if ( empty($current) ) + return; + + deactivate_plugins($current); + + update_option('deactivated_plugins', $current); +} + +function reactivate_all_plugins($redirect = '') { + $plugins = get_option('deactivated_plugins'); + + if ( empty($plugins) ) + return; + + if ( !empty($redirect) ) + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); + + $errors = array(); + foreach ( (array) $plugins as $plugin ) { + $result = activate_plugin($plugin); + if ( is_wp_error($result) ) + $errors[$plugin] = $result; + } + + delete_option('deactivated_plugins'); + + if ( !empty($errors) ) + return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); + + return true; +} + +function validate_active_plugins() { + $check_plugins = get_option('active_plugins'); + + // Sanity check. If the active plugin list is not an array, make it an + // empty array. + if ( !is_array($check_plugins) ) { + update_option('active_plugins', array()); + return; + } + + // If a plugin file does not exist, remove it from the list of active + // plugins. + foreach ( $check_plugins as $check_plugin ) { + if ( !file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin) ) { + $current = get_option('active_plugins'); + $key = array_search($check_plugin, $current); + if ( false !== $key && NULL !== $key ) { + unset($current[$key]); + update_option('active_plugins', $current); + } + } + } +} + +function validate_plugin($plugin) { + if ( validate_file($plugin) ) + return new WP_Error('plugin_invalid', __('Invalid plugin.')); + if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) + return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); + + return 0; +} + // // Menu // @@ -111,7 +224,6 @@ function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $fi global $menu; global $_wp_real_parent_file; global $_wp_submenu_nopriv; - global $_wp_menu_nopriv; $file = plugin_basename( $file ); @@ -287,10 +399,8 @@ function get_admin_page_title() { } function get_plugin_page_hook( $plugin_page, $parent_page ) { - global $wp_filter; - $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); - if ( isset( $wp_filter[$hook] )) + if ( has_action($hook) ) return $hook; else return null; diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index acd6e64..2ee6210 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -2,7 +2,6 @@ // Update an existing post with values provided in $_POST. function edit_post() { - global $user_ID; $post_ID = (int) $_POST['post_ID']; @@ -19,8 +18,7 @@ function edit_post() { $post =& get_post( $post_ID ); $now = time(); $then = strtotime($post->post_date_gmt . ' +0000'); - // Keep autosave_interval in sync with autosave-js.php. - $delta = apply_filters( 'autosave_interval', 120 ) / 2; + $delta = AUTOSAVE_INTERVAL / 2; if ( ($now - $then) < $delta ) return $post_ID; } @@ -29,7 +27,7 @@ function edit_post() { $_POST['ID'] = (int) $_POST['post_ID']; $_POST['post_content'] = $_POST['content']; $_POST['post_excerpt'] = $_POST['excerpt']; - $_POST['post_parent'] = $_POST['parent_id']; + $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : ''; $_POST['to_ping'] = $_POST['trackback_url']; if (!empty ( $_POST['post_author_override'] ) ) { @@ -53,20 +51,20 @@ function edit_post() { } // What to do based on which button they pressed - if ('' != $_POST['saveasdraft'] ) + if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] ) $_POST['post_status'] = 'draft'; - if ('' != $_POST['saveasprivate'] ) + if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] ) $_POST['post_status'] = 'private'; - if ('' != $_POST['publish'] ) + if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) ) $_POST['post_status'] = 'publish'; - if ('' != $_POST['advanced'] ) + if ( isset($_POST['advanced']) && '' != $_POST['advanced'] ) $_POST['post_status'] = 'draft'; if ( 'page' == $_POST['post_type'] ) { - if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) + if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' )) $_POST['post_status'] = 'pending'; } else { - if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) + if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' )) $_POST['post_status'] = 'pending'; } @@ -76,6 +74,13 @@ function edit_post() { if (!isset( $_POST['ping_status'] )) $_POST['ping_status'] = 'closed'; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -92,12 +97,12 @@ function edit_post() { } // Meta Stuff - if ( $_POST['meta'] ) { + if ( isset($_POST['meta']) && $_POST['meta'] ) { foreach ( $_POST['meta'] as $key => $value ) update_meta( $key, $value['key'], $value['value'] ); } - if ( $_POST['deletemeta'] ) { + if ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { foreach ( $_POST['deletemeta'] as $key => $value ) delete_meta( $key ); } @@ -115,6 +120,8 @@ function edit_post() { // Now that we have an ID we can fix any attachment anchor hrefs _fix_attachment_links( $post_ID ); + wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); + return $post_ID; } @@ -129,6 +136,7 @@ function get_default_post_to_edit() { $post_title = ''; } + $post_content = ''; if ( !empty( $_REQUEST['content'] ) ) $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] )); else if ( !empty( $post_title ) ) { @@ -143,7 +151,14 @@ function get_default_post_to_edit() { else $post_excerpt = ''; + $post->ID = 0; + $post->post_name = ''; + $post->post_author = ''; + $post->post_date = ''; $post->post_status = 'draft'; + $post->post_type = 'post'; + $post->to_ping = ''; + $post->pinged = ''; $post->comment_status = get_option( 'default_comment_status' ); $post->ping_status = get_option( 'default_ping_status' ); $post->post_pingback = get_option( 'default_pingback_flag' ); @@ -158,6 +173,12 @@ function get_default_post_to_edit() { return $post; } +function get_default_page_to_edit() { + $page = get_default_post_to_edit(); + $page->post_type = 'page'; + return $page; +} + // Get an existing post and format it for editing. function get_post_to_edit( $id ) { @@ -218,7 +239,7 @@ function wp_write_post() { // Rename. $_POST['post_content'] = $_POST['content']; $_POST['post_excerpt'] = $_POST['excerpt']; - $_POST['post_parent'] = $_POST['parent_id']; + $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : ''; $_POST['to_ping'] = $_POST['trackback_url']; if (!empty ( $_POST['post_author_override'] ) ) { @@ -244,13 +265,13 @@ function wp_write_post() { } // What to do based on which button they pressed - if ('' != $_POST['saveasdraft'] ) + if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] ) $_POST['post_status'] = 'draft'; - if ('' != $_POST['saveasprivate'] ) + if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] ) $_POST['post_status'] = 'private'; - if ('' != $_POST['publish'] ) + if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) ) $_POST['post_status'] = 'publish'; - if ('' != $_POST['advanced'] ) + if ( isset($_POST['advanced']) && '' != $_POST['advanced'] ) $_POST['post_status'] = 'draft'; if ( 'page' == $_POST['post_type'] ) { @@ -267,6 +288,13 @@ function wp_write_post() { if (!isset( $_POST['ping_status'] )) $_POST['ping_status'] = 'closed'; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -309,6 +337,8 @@ function wp_write_post() { // Now that we have an ID we can fix any attachment anchor hrefs _fix_attachment_links( $post_ID ); + wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); + return $post_ID; } @@ -348,11 +378,13 @@ function add_meta( $post_ID ) { if ( in_array($metakey, $protected) ) return false; - $result = $wpdb->query( " - INSERT INTO $wpdb->postmeta - (post_id,meta_key,meta_value ) - VALUES ('$post_ID','$metakey','$metavalue' ) - " ); + wp_cache_delete($post_ID, 'post_meta'); + + $wpdb->query( " + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value ) + VALUES ('$post_ID','$metakey','$metavalue' ) + " ); return $wpdb->insert_id; } return false; @@ -362,6 +394,9 @@ function delete_meta( $mid ) { global $wpdb; $mid = (int) $mid; + $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + wp_cache_delete($post_id, 'post_meta'); + return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); } @@ -408,6 +443,9 @@ function update_meta( $mid, $mkey, $mvalue ) { if ( in_array($mkey, $protected) ) return false; + $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + wp_cache_delete($post_id, 'post_meta'); + $mvalue = maybe_serialize( stripslashes( $mvalue )); $mvalue = $wpdb->escape( $mvalue ); $mid = (int) $mid; @@ -420,7 +458,6 @@ function update_meta( $mid, $mkey, $mvalue ) { // Replace hrefs of attachment anchors with up-to-date permalinks. function _fix_attachment_links( $post_ID ) { - global $wp_rewrite; $post = & get_post( $post_ID, ARRAY_A ); @@ -468,4 +505,191 @@ function _relocate_children( $old_ID, $new_ID ) { return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); } +function get_available_post_statuses($type = 'post') { + global $wpdb; + + $stati = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = %s", $type)); + return $stati; +} + +function wp_edit_posts_query( $q = false ) { + global $wpdb; + if ( false === $q ) + $q = $_GET; + $q['m'] = (int) $q['m']; + $q['cat'] = (int) $q['cat']; + $post_stati = array( // array( adj, noun ) + 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')), + 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), + 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')), + 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')), + 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')), + ); + + $post_stati = apply_filters('post_stati', $post_stati); + + $avail_post_stati = get_available_post_statuses('post'); + + $post_status_q = ''; + if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { + $post_status_q = '&post_status=' . $q['post_status']; + $post_status_q .= '&perm=readable'; + } + + if ( 'pending' === $q['post_status'] ) { + $order = 'ASC'; + $orderby = 'modified'; + } elseif ( 'draft' === $q['post_status'] ) { + $order = 'DESC'; + $orderby = 'modified'; + } else { + $order = 'DESC'; + $orderby = 'date'; + } + + wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby"); + + return array($post_stati, $avail_post_stati); +} + +function get_available_post_mime_types($type = 'attachment') { + global $wpdb; + + $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); + return $types; +} + +function wp_edit_attachments_query( $q = false ) { + global $wpdb; + if ( false === $q ) + $q = $_GET; + $q['m'] = (int) $q['m']; + $q['cat'] = (int) $q['cat']; + $q['post_type'] = 'attachment'; + $q['post_status'] = 'any'; + $q['posts_per_page'] = 15; + $post_mime_types = array( // array( adj, noun ) + 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')), + 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')), + 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')), + ); + $post_mime_types = apply_filters('post_mime_types', $post_mime_types); + + $avail_post_mime_types = get_available_post_mime_types('attachment'); + + if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) + unset($q['post_mime_type']); + + wp($q); + + return array($post_mime_types, $avail_post_mime_types); +} + +function postbox_classes( $id, $page ) { + $current_user = wp_get_current_user(); + if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) { + if ( !is_array( $closed ) ) return ''; + return in_array( $id, $closed )? 'if-js-closed' : ''; + } else { + if ( 'tagsdiv' == $id || 'categorydiv' == $id ) return ''; + else return 'if-js-closed'; + } +} + +function get_sample_permalink($id, $title=null, $name = null) { + $post = &get_post($id); + if (!$post->ID) { + return array('', ''); + } + $original_status = $post->post_status; + $original_date = $post->post_date; + $original_name = $post->post_name; + + // Hack: get_permalink would return ugly permalink for + // drafts, so we will fake, that our post is published + if (in_array($post->post_status, array('draft', 'pending'))) { + $post->post_status = 'publish'; + $post->post_date = date('Y-m-d H:i:s'); + $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); + } + + // If the user wants to set a new name -- override the current one + // Note: if empty name is supplied -- use the title instead, see #6072 + if (!is_null($name)) { + $post->post_name = sanitize_title($name? $name : $title, $post->ID); + } + + $permalink = get_permalink($post, true); + + // Handle page hierarchy + if ( 'page' == $post->post_type ) { + $uri = get_page_uri($post->ID); + $uri = untrailingslashit($uri); + $uri = strrev( stristr( strrev( $uri ), '/' ) ); + $uri = untrailingslashit($uri); + if ( !empty($uri) ) + $uri .='/'; + $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); + } + + $permalink = array($permalink, $post->post_name); + $post->post_status = $original_status; + $post->post_date = $original_date; + $post->post_name = $original_name; + $post->post_title = $original_title; + return $permalink; +} + +function get_sample_permalink_html($id, $new_title=null, $new_slug=null) { + $post = &get_post($id); + list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { + return ''; + } + $title = __('Click to edit this part of the permalink'); + if (strlen($post_name) > 30) { + $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14); + } else { + $post_name_abridged = $post_name; + } + $post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>'; + $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); + $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $display_link . "</span>\n"; + $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n"; + return $return; +} + +// false: not locked or locked by current user +// int: user ID of user with lock +function wp_check_post_lock( $post_id ) { + global $current_user; + + if ( !$post = get_post( $post_id ) ) + return false; + + $lock = get_post_meta( $post->ID, '_edit_lock', true ); + $last = get_post_meta( $post->ID, '_edit_last', true ); + + $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); + + if ( $lock && $lock > time() - $time_window && $last != $current_user->ID ) + return $last; + return false; +} + +function wp_set_post_lock( $post_id ) { + global $current_user; + if ( !$post = get_post( $post_id ) ) + return false; + if ( !$current_user || !$current_user->ID ) + return false; + + $now = time(); + + if ( !add_post_meta( $post->ID, '_edit_lock', $now, true ) ) + update_post_meta( $post->ID, '_edit_lock', $now ); + if ( !add_post_meta( $post->ID, '_edit_last', $current_user->ID, true ) ) + update_post_meta( $post->ID, '_edit_last', $current_user->ID ); +} + ?> diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 310c2c1..7b78d93 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -1,10 +1,12 @@ <?php // Here we keep the DB structure and option values -global $wp_queries; $charset_collate = ''; -if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { +// Declare these as global in case schema.php is included from a function. +global $wpdb, $wp_queries; + +if ( $wpdb->supports_collation() ) { if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) @@ -32,6 +34,7 @@ CREATE TABLE $wpdb->term_taxonomy ( CREATE TABLE $wpdb->term_relationships ( object_id bigint(20) NOT NULL default 0, term_taxonomy_id bigint(20) NOT NULL default 0, + term_order int(11) NOT NULL default 0, PRIMARY KEY (object_id,term_taxonomy_id), KEY term_taxonomy_id (term_taxonomy_id) ) $charset_collate; @@ -46,14 +49,16 @@ CREATE TABLE $wpdb->comments ( comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', comment_content text NOT NULL, comment_karma int(11) NOT NULL default '0', - comment_approved enum('0','1','spam') NOT NULL default '1', + comment_approved varchar(20) NOT NULL default '1', comment_agent varchar(255) NOT NULL default '', comment_type varchar(20) NOT NULL default '', comment_parent bigint(20) NOT NULL default '0', user_id bigint(20) NOT NULL default '0', PRIMARY KEY (comment_ID), KEY comment_approved (comment_approved), - KEY comment_post_ID (comment_post_ID) + KEY comment_post_ID (comment_post_ID), + KEY comment_approved_date_gmt (comment_approved,comment_date_gmt), + KEY comment_date_gmt (comment_date_gmt) ) $charset_collate; CREATE TABLE $wpdb->links ( link_id bigint(20) NOT NULL auto_increment, @@ -63,7 +68,7 @@ CREATE TABLE $wpdb->links ( link_target varchar(25) NOT NULL default '', link_category bigint(20) NOT NULL default '0', link_description varchar(255) NOT NULL default '', - link_visible enum('Y','N') NOT NULL default 'Y', + link_visible varchar(20) NOT NULL default 'Y', link_owner int(11) NOT NULL default '1', link_rating int(11) NOT NULL default '0', link_updated datetime NOT NULL default '0000-00-00 00:00:00', @@ -79,7 +84,7 @@ CREATE TABLE $wpdb->options ( blog_id int(11) NOT NULL default '0', option_name varchar(64) NOT NULL default '', option_value longtext NOT NULL, - autoload enum('yes','no') NOT NULL default 'yes', + autoload varchar(20) NOT NULL default 'yes', PRIMARY KEY (option_id,blog_id,option_name), KEY option_name (option_name) ) $charset_collate; @@ -101,9 +106,9 @@ CREATE TABLE $wpdb->posts ( post_title text NOT NULL, post_category int(4) NOT NULL default '0', post_excerpt text NOT NULL, - post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish', - comment_status enum('open','closed','registered_only') NOT NULL default 'open', - ping_status enum('open','closed') NOT NULL default 'open', + post_status varchar(20) NOT NULL default 'publish', + comment_status varchar(20) NOT NULL default 'open', + ping_status varchar(20) NOT NULL default 'open', post_password varchar(20) NOT NULL default '', post_name varchar(200) NOT NULL default '', to_ping text NOT NULL, @@ -301,7 +306,7 @@ function populate_options() { } // 2.0.3 - add_option('secret', md5(uniqid(microtime()))); + add_option('secret', wp_generate_password()); // 2.1 add_option('blog_public', '1'); @@ -311,8 +316,18 @@ function populate_options() { // 2.2 add_option('tag_base'); + // 2.5 + add_option('show_avatars', '1'); + add_option('avatar_rating', 'G'); + add_option('upload_url_path', ''); + add_option('thumbnail_size_w', 150); + add_option('thumbnail_size_h', 150); + add_option('thumbnail_crop', 1); + add_option('medium_size_w', 300); + add_option('medium_size_h', 300); + // Delete unused options - $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing'); + $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval'); foreach ($unusedoptions as $option) : delete_option($option); endforeach; @@ -328,17 +343,24 @@ function populate_roles() { populate_roles_160(); populate_roles_210(); populate_roles_230(); + populate_roles_250(); } function populate_roles_160() { - global $wp_roles; - // Add roles - add_role('administrator', __('Administrator')); - add_role('editor', __('Editor')); - add_role('author', __('Author')); - add_role('contributor', __('Contributor')); - add_role('subscriber', __('Subscriber')); + + // Dummy gettext calls to get strings in the catalog. + _c('Administrator|User role'); + _c('Editor|User role'); + _c('Author|User role'); + _c('Contributor|User role'); + _c('Subscriber|User role'); + + add_role('administrator', 'Administrator|User role'); + add_role('editor', 'Editor|User role'); + add_role('author', 'Author|User role'); + add_role('contributor', 'Contributor|User role'); + add_role('subscriber', 'Subscriber|User role'); // Add caps for Administrator role $role = get_role('administrator'); @@ -469,4 +491,12 @@ function populate_roles_230() { */ } +function populate_roles_250() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'edit_dashboard' ); + } +} + ?> diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index 3f70f45..b490ed6 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -16,11 +16,11 @@ function get_category_to_edit( $id ) { return $category; } -function wp_create_category($cat_name) { +function wp_create_category( $cat_name, $parent = 0 ) { if ( $id = category_exists($cat_name) ) return $id; - return wp_insert_category( array('cat_name' => $cat_name) ); + return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) ); } function wp_create_categories($categories, $post_id = '') { @@ -40,8 +40,6 @@ function wp_create_categories($categories, $post_id = '') { } function wp_delete_category($cat_ID) { - global $wpdb; - $cat_ID = (int) $cat_ID; $default = get_option('default_category'); @@ -52,13 +50,17 @@ function wp_delete_category($cat_ID) { return wp_delete_term($cat_ID, 'category', "default=$default"); } -function wp_insert_category($catarr) { - global $wpdb; - +function wp_insert_category($catarr, $wp_error = false) { + $cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => ''); + $cat_arr = wp_parse_args($cat_arr, $cat_defaults); extract($catarr, EXTR_SKIP); - if ( trim( $cat_name ) == '' ) - return 0; + if ( trim( $cat_name ) == '' ) { + if ( ! $wp_error ) + return 0; + else + return new WP_Error( 'cat_name', __('You did not enter a category name.') ); + } $cat_ID = (int) $cat_ID; @@ -74,6 +76,9 @@ function wp_insert_category($catarr) { $parent = $category_parent; $parent = (int) $parent; + if ( $parent < 0 ) + $parent = 0; + if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) ) $parent = 0; @@ -84,15 +89,17 @@ function wp_insert_category($catarr) { else $cat_ID = wp_insert_term($cat_name, 'category', $args); - if ( is_wp_error($cat_ID) ) - return 0; + if ( is_wp_error($cat_ID) ) { + if ( $wp_error ) + return $cat_ID; + else + return 0; + } return $cat_ID['term_id']; } function wp_update_category($catarr) { - global $wpdb; - $cat_ID = (int) $catarr['cat_ID']; if ( $cat_ID == $catarr['category_parent'] ) @@ -115,8 +122,6 @@ function wp_update_category($catarr) { // function get_tags_to_edit( $post_id ) { - global $wpdb; - $post_id = (int) $post_id; if ( !$post_id ) return false; @@ -145,4 +150,4 @@ function wp_create_tag($tag_name) { return wp_insert_term($tag_name, 'post_tag'); } -?>
\ No newline at end of file +?> diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index ff809ec..3e67338 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -6,8 +6,12 @@ // Dandy new recursive multiple category stuff. function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { - if ( !$categories ) - $categories = get_categories( 'hide_empty=0' ); + if ( !$categories ) { + $args = array('hide_empty' => 0); + if ( !empty($_GET['s']) ) + $args['search'] = $_GET['s']; + $categories = get_categories( $args ); + } $children = _get_term_hierarchy('category'); @@ -34,43 +38,68 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { function _cat_row( $category, $level, $name_override = false ) { global $class; + $category = get_category( $category ); + $pad = str_repeat( '— ', $level ); + $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); if ( current_user_can( 'manage_categories' ) ) { - $edit = "<a href='categories.php?action=edit&cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>"; - $default_cat_id = (int) get_option( 'default_category' ); - $default_link_cat_id = (int) get_option( 'default_link_category' ); - - if ( $category->term_id != $default_cat_id ) - $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>"; - else - $edit .= "<td style='text-align:center'>".__( "Default" ); - } else - $edit = ''; + $edit = "<a class='row-title' href='categories.php?action=edit&cat_ID=$category->term_id' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a>"; + } else { + $edit = $name; + } - $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; + $class = " class='alternate'" == $class ? '' : " class='alternate'"; $category->count = number_format_i18n( $category->count ); $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count; $output = "<tr id='cat-$category->term_id'$class> - <th scope='row' style='text-align: center'>$category->term_id</th> - <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td> - <td>$category->description</td> - <td align='center'>$posts_count</td> - <td>$edit</td>\n\t</tr>\n"; + <th scope='row' class='check-column'>"; + if ( absint(get_option( 'default_category' ) ) != $category->term_id ) { + $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' /></th>"; + } else { + $output .= " "; + } + $output .= "<td>$edit</td> + <td>$category->description</td> + <td class='num'>$posts_count</td>\n\t</tr>\n"; return apply_filters('cat_row', $output); } +function link_cat_row( $category ) { + global $class; + + if ( !$category = get_term( $category, 'link_category' ) ) + return false; + if ( is_wp_error( $category ) ) + return $category; + + $name = ( $name_override ? $name_override : $category->name ); + if ( current_user_can( 'manage_categories' ) ) { + $edit = "<a class='row-title' href='link-category.php?action=edit&cat_ID=$category->term_id' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "' class='edit'>$name</a>"; + $default_cat_id = (int) get_option( 'default_link_category' ); + } else { + $edit = $name; + } + + $class = " class='alternate'" == $class ? '' : " class='alternate'"; + + $category->count = number_format_i18n( $category->count ); + $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; + $output = "<tr id='link-cat-$category->term_id'$class>" . + '<th scope="row" class="check-column"> <input type="checkbox" name="delete[]" value="' . $category->term_id . '" /></th>' . + "<td>$edit</td> + <td>$category->description</td> + <td class='num'>$count</td></tr>"; + + return apply_filters( 'link_cat_row', $output ); +} + function checked( $checked, $current) { if ( $checked == $current) echo ' checked="checked"'; } -// TODO: Remove? -function documentation_link( $for ) { - return; -} - function selected( $selected, $current) { if ( $selected == $current) echo ' selected="selected"'; @@ -87,8 +116,8 @@ function sort_cats( $cat1, $cat2 ) { return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] ); } -function get_nested_categories( $default = 0, $parent = 0 ) { - global $post_ID, $mode, $wpdb, $checked_categories; +function wp_set_checked_post_categories( $default = 0 ) { + global $post_ID, $checked_categories; if ( empty($checked_categories) ) { if ( $post_ID ) { @@ -103,15 +132,33 @@ function get_nested_categories( $default = 0, $parent = 0 ) { } } - $cats = get_categories("parent=$parent&hide_empty=0&fields=ids"); +} +function get_nested_categories( $default = 0, $parent = 0 ) { + global $checked_categories; + + wp_set_checked_post_categories( $default = 0 ); + + if ( is_object($parent) ) { // Hack: if passed a category object, will return nested cats with parent as root + $root = array( + 'children' => get_nested_categories( $default, $parent->term_id ), + 'cat_ID' => $parent->term_id, + 'checked' => in_array( $parent->term_id, $checked_categories ), + 'cat_name' => get_the_category_by_ID( $parent->term_id ) + ); + $result = array( $parent->term_id => $root ); + } else { + $parent = (int) $parent; + + $cats = get_categories("parent=$parent&hide_empty=0&fields=ids"); - $result = array (); - if ( is_array( $cats ) ) { - foreach ( $cats as $cat) { - $result[$cat]['children'] = get_nested_categories( $default, $cat); - $result[$cat]['cat_ID'] = $cat; - $result[$cat]['checked'] = in_array( $cat, $checked_categories ); - $result[$cat]['cat_name'] = get_the_category_by_ID( $cat); + $result = array(); + if ( is_array( $cats ) ) { + foreach ( $cats as $cat ) { + $result[$cat]['children'] = get_nested_categories( $default, $cat ); + $result[$cat]['cat_ID'] = $cat; + $result[$cat]['checked'] = in_array( $cat, $checked_categories ); + $result[$cat]['cat_name'] = get_the_category_by_ID( $cat ); + } } } @@ -123,18 +170,37 @@ function get_nested_categories( $default = 0, $parent = 0 ) { function write_nested_categories( $categories ) { foreach ( $categories as $category ) { - 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( apply_filters('the_category', $category['cat_name'] )), "</label></li>"; + echo "\n", '<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( apply_filters('the_category', $category['cat_name'] )), '</label>'; if ( $category['children'] ) { - echo "<ul>\n"; + echo "\n<ul>"; write_nested_categories( $category['children'] ); - echo "</ul>\n"; + echo "\n</ul>"; } + echo '</li>'; } } -function dropdown_categories( $default = 0 ) { - write_nested_categories( get_nested_categories( $default) ); +function dropdown_categories( $default = 0, $parent = 0 ) { + write_nested_categories( get_nested_categories( $default, $parent ) ); +} + +function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) { + $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) ); + + foreach ( (array) $categories as $category ) { + $id = "popular-category-$category->term_id"; + ?> + + <li id="<?php echo $id; ?>" > + <label class="selectit" for="in-<?php echo $id; ?>"> + <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" /> + <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?> + </label> + </li> + + <?php + } } function dropdown_link_categories( $default = 0 ) { @@ -164,46 +230,309 @@ function dropdown_link_categories( $default = 0 ) { } } -function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { - global $wpdb, $class, $post; +// Tag stuff - if (!$pages ) - $pages = get_pages( 'sort_column=menu_order' ); +// Returns a single tag row (see tag_rows below) +// Note: this is also used in admin-ajax.php! +function _tag_row( $tag, $class = '' ) { + $count = number_format_i18n( $tag->count ); + $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count; - if (! $pages ) - return false; + $name = apply_filters( 'term_name', $tag->name ); + $out = ''; + $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; + $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>'; + $out .= '<td><strong><a class="row-title" href="edit-tags.php?action=edit&tag_ID=' . $tag->term_id . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . + $name . '</a></td>'; + + $out .= "<td class='num'>$count</td>"; + $out .= '</tr>'; + + return $out; +} - foreach ( $pages as $post) { - setup_postdata( $post); - if ( $hierarchy && ($post->post_parent != $parent) ) - continue; +// Outputs appropriate rows for the Nth page of the Tag Management screen, +// assuming M tags displayed at a time on the page +// Returns the number of tags displayed +function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { - $post->post_title = wp_specialchars( $post->post_title ); - $pad = str_repeat( '— ', $level ); - $id = (int) $post->ID; - $class = ('alternate' == $class ) ? '' : 'alternate'; + // Get a page worth of tags + $start = ($page - 1) * $pagesize; + + $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); + + if ( !empty( $searchterms ) ) { + $args['search'] = $searchterms; + } + + $tags = get_terms( 'post_tag', $args ); + + // convert it to table rows + $out = ''; + $class = ''; + $count = 0; + foreach( $tags as $tag ) + $out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '' ); + + // filter and send to screen + $out = apply_filters('tag_rows', $out); + echo $out; + return $count; +} + +// define the columns to display, the syntax is 'internal name' => 'display name' +function wp_manage_posts_columns() { + $posts_columns = array(); + $posts_columns['cb'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />'; + if ( 'draft' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Modified'); + elseif ( 'pending' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Submitted'); + else + $posts_columns['date'] = __('Date'); + $posts_columns['title'] = __('Title'); + $posts_columns['author'] = __('Author'); + $posts_columns['categories'] = __('Categories'); + $posts_columns['tags'] = __('Tags'); + if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) + $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; + $posts_columns['status'] = __('Status'); + $posts_columns = apply_filters('manage_posts_columns', $posts_columns); + + return $posts_columns; +} + +// define the columns to display, the syntax is 'internal name' => 'display name' +function wp_manage_media_columns() { + $posts_columns = array(); + $posts_columns['cb'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />'; + $posts_columns['icon'] = ''; + $posts_columns['media'] = _c('Media|media column header'); + $posts_columns['desc'] = _c('Description|media column header'); + $posts_columns['date'] = _c('Date Added|media column header'); + $posts_columns['parent'] = _c('Appears with|media column header'); + $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; + $posts_columns['location'] = _c('Location|media column header'); + $posts_columns = apply_filters('manage_media_columns', $posts_columns); + + return $posts_columns; +} + +function wp_manage_pages_columns() { + $posts_columns = array(); + $posts_columns['cb'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />'; + if ( 'draft' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Modified'); + elseif ( 'pending' === $_GET['post_status'] ) + $posts_columns['modified'] = __('Submitted'); + else + $posts_columns['date'] = __('Date'); + $posts_columns['title'] = __('Title'); + $posts_columns['author'] = __('Author'); + if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) + $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>'; + $posts_columns['status'] = __('Status'); + $posts_columns = apply_filters('manage_pages_columns', $posts_columns); + + return $posts_columns; +} + +/* + * display one row if the page doesn't have any children + * otherwise, display the row and its children in subsequent rows + */ +function display_page_row( $page, &$children_pages, $level = 0 ) { + global $post; + static $class; + + $post = $page; + setup_postdata($page); + + $page->post_title = wp_specialchars( $page->post_title ); + $pad = str_repeat( '— ', $level ); + $id = (int) $page->ID; + $class = ('alternate' == $class ) ? '' : 'alternate'; + $posts_columns = wp_manage_pages_columns(); + $title = get_the_title(); + if ( empty($title) ) + $title = __('(no title)'); ?> <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> - <th scope="row" style="text-align: center"><?php echo $post->ID; ?></th> - <td> - <?php echo $pad; ?><?php the_title() ?> - </td> - <td><?php the_author() ?></td> - <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td> - <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td> - <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td> - <td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&post=$id", 'delete-page_' . $id ) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . js_escape(sprintf( __("You are about to delete the '%s' page.\n'OK' to delete, 'Cancel' to stop." ), get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td> - </tr> + + + <?php + +foreach ($posts_columns as $column_name=>$column_display_name) { + + switch ($column_name) { + + case 'cb': + ?> + <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th> + <?php + break; + case 'modified': + case 'date': + if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) { + $t_time = $h_time = __('Unpublished'); + } else { + if ( 'modified' == $column_name ) { + $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); + $m_time = $page->post_modified; + $time = get_post_modified_time('G', true); + } else { + $t_time = get_the_time(__('Y/m/d g:i:s A')); + $m_time = $page->post_date; + $time = get_post_time('G', true); + } + if ( ( abs(time() - $time) ) < 86400 ) { + if ( ( 'future' == $page->post_status) ) + $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); + else + $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); + } else { + $h_time = mysql2date(__('Y/m/d'), $m_time); + } + } + ?> + <td><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td> + <?php + break; + case 'title': + ?> + <td><strong><a class="row-title" href="page.php?action=edit&post=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a></strong> + <?php if ('private' == $page->post_status) _e(' — <strong>Private</strong>'); ?></td> + <?php + break; + + case 'comments': + ?> + <td class="num"><div class="post-com-count-wrapper"> + <?php + $left = get_pending_comments_num( $page->ID ); + $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); + if ( $left ) + echo '<strong>'; + comments_number("<a href='edit-pages.php?page_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-pages.php?page_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-pages.php?page_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); + if ( $left ) + echo '</strong>'; + ?> + </div></td> + <?php + break; + + case 'author': + ?> + <td><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td> + <?php + break; + + case 'status': + ?> + <td> + <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink"> + <?php + switch ( $page->post_status ) { + case 'publish' : + case 'private' : + _e('Published'); + break; + case 'future' : + _e('Scheduled'); + break; + case 'pending' : + _e('Pending Review'); + break; + case 'draft' : + _e('Unpublished'); + break; + } + ?> + </a> + </td> + <?php + break; + + default: + ?> + <td><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td> + <?php + break; + } +} + ?> + + </tr> <?php - if ( $hierarchy ) page_rows( $id, $level + 1, $pages ); + + if ( ! $children_pages ) + return true; + + for ( $i = 0; $i < count($children_pages); $i++ ) { + + $child = $children_pages[$i]; + + if ( $child->post_parent == $id ) { + array_splice($children_pages, $i, 1); + display_page_row($child, $children_pages, $level+1); + $i = -1; //as numeric keys in $children_pages are not preserved after splice + } + } +} + +/* + * displays pages in hierarchical order + */ +function page_rows( $pages ) { + if ( ! $pages ) + $pages = get_pages( 'sort_column=menu_order' ); + + if ( ! $pages ) + return false; + + // splice pages into two parts: those without parent and those with parent + + $top_level_pages = array(); + $children_pages = array(); + + foreach ( $pages as $page ) { + + // catch and repair bad pages + if ( $page->post_parent == $page->ID ) { + $page->post_parent = 0; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) ); + clean_page_cache( $page->ID ); + } + + if ( 0 == $page->post_parent ) + $top_level_pages[] = $page; + else + $children_pages[] = $page; } + + foreach ( $top_level_pages as $page ) + display_page_row($page, $children_pages, 0); + + /* + * display the remaining children_pages which are orphans + * having orphan requires parental attention + */ + if ( count($children_pages) > 0 ) { + $empty_array = array(); + foreach ( $children_pages as $orphan_page ) { + clean_page_cache( $orphan_page->ID); + display_page_row( $orphan_page, $empty_array, 0 ); + } + } } -function user_row( $user_object, $style = '' ) { - global $current_user; +function user_row( $user_object, $style = '', $role = '' ) { + global $wp_roles; - if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) + $current_user = wp_get_current_user(); + + if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) $user_object = new WP_User( (int) $user_object ); $email = $user_object->user_email; $url = $user_object->user_url; @@ -214,33 +543,50 @@ function user_row( $user_object, $style = '' ) { if ( strlen( $short_url ) > 35 ) $short_url = substr( $short_url, 0, 32 ).'...'; $numposts = get_usernumposts( $user_object->ID ); + if ( current_user_can( 'edit_user', $user_object->ID ) ) { + if ($current_user->ID == $user_object->ID) { + $edit = 'profile.php'; + } else { + $edit = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); + } + $edit = "<a href=\"$edit\">$user_object->user_login</a>"; + } else { + $edit = $user_object->user_login; + } + $role_name = translate_with_context($wp_roles->role_names[$role]); $r = "<tr id='user-$user_object->ID'$style> - <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td> - <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> - <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> + <th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th> + <td><strong>$edit</strong></td> + <td>$user_object->first_name $user_object->last_name</td> <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td> - <td><a href='$url' title='website: $url'>$short_url</a></td>"; - $r .= "\n\t\t<td align='center'>"; + <td>$role_name</td>"; + $r .= "\n\t\t<td class='num'>"; if ( $numposts > 0 ) { $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; - $r .= sprintf(__ngettext( 'View %s post', 'View %s posts', $numposts ), $numposts); + $r .= $numposts; $r .= '</a>'; - } - $r .= "</td>\n\t\t<td>"; - if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can( 'edit_user', $user_object->ID ) ) { - $edit_link = add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ); - $r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>"; + } else { + $r .= 0; } $r .= "</td>\n\t</tr>"; return $r; } -function _wp_get_comment_list( $s = false, $start, $num ) { +function _wp_get_comment_list( $status = '', $s = false, $start, $num ) { global $wpdb; $start = abs( (int) $start ); $num = (int) $num; + if ( 'moderated' == $status ) + $approved = "comment_approved = '0'"; + elseif ( 'approved' == $status ) + $approved = "comment_approved = '1'"; + elseif ( 'spam' == $status ) + $approved = "comment_approved = 'spam'"; + else + $approved = "comment_approved != 'spam'"; + if ( $s ) { $s = $wpdb->escape($s); $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE @@ -249,10 +595,10 @@ function _wp_get_comment_list( $s = false, $start, $num ) { comment_author_url LIKE ('%$s%') OR comment_author_IP LIKE ('%$s%') OR comment_content LIKE ('%$s%') ) AND - comment_approved != 'spam' - ORDER BY comment_date DESC LIMIT $start, $num"); + $approved + ORDER BY comment_date_gmt DESC LIMIT $start, $num"); } else { - $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); + $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments USE INDEX (comment_date_gmt) WHERE $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); } update_comment_cache($comments); @@ -262,46 +608,95 @@ function _wp_get_comment_list( $s = false, $start, $num ) { return array($comments, $total); } -function _wp_comment_list_item( $id, $alt = 0 ) { - global $authordata, $comment, $wpdb; - $id = (int) $id; - $comment =& get_comment( $id ); - $class = ''; +function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true ) { + global $comment, $post; + $comment = get_comment( $comment_id ); $post = get_post($comment->comment_post_ID); $authordata = get_userdata($post->post_author); - $comment_status = wp_get_comment_status($comment->comment_ID); - if ( 'unapproved' == $comment_status ) - $class .= ' unapproved'; - if ( $alt % 2 ) - $class .= ' alternate'; - echo "<li id='comment-$comment->comment_ID' class='$class'>"; -?> -<p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> + $the_comment_status = wp_get_comment_status($comment->comment_ID); + $class = ('unapproved' == $the_comment_status) ? 'unapproved' : ''; -<?php comment_text() ?> + if ( current_user_can( 'edit_post', $post->ID ) ) { + $post_link = "<a href='" . get_comment_link() . "'>"; -<p><?php comment_date(__('M j, g:i A')); ?> — [ -<?php -if ( current_user_can('edit_post', $comment->comment_post_ID) ) { - echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; - echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; - if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { - echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; - echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; + $post_link .= get_the_title($comment->comment_post_ID) . '</a>'; + + $edit_link_start = "<a class='row-title' href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>"; + $edit_link_end = '</a>'; + } else { + $post_link = get_the_title($comment->comment_post_ID); + $edit_link_start = $edit_link_end =''; } - echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; -} -$post = get_post($comment->comment_post_ID, OBJECT, 'display'); -$post_title = wp_specialchars( $post->post_title, 'double' ); -$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; + + $author_url = get_comment_author_url(); + if ( 'http://' == $author_url ) + $author_url = ''; + $author_url_display = $author_url; + if ( strlen($author_url_display) > 50 ) + $author_url_display = substr($author_url_display, 0, 49) . '...'; + + $ptime = date('G', strtotime( $comment->comment_date ) ); + if ( ( abs(time() - $ptime) ) < 86400 ) + $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); + else + $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); + + $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); + $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); + $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); + ?> - ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> - </li> + <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> +<?php if ( $checkbox ) : ?> + <td class="check-column"><?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> +<?php endif; ?> + <td class="comment"> + <p class="comment-author"><strong><?php echo $edit_link_start; comment_author(); echo $edit_link_end; ?></strong><br /> + <?php if ( !empty($author_url) ) : ?> + <a href="<?php echo $author_url ?>"><?php echo $author_url_display; ?></a> | + <?php endif; ?> + <?php if ( current_user_can( 'edit_post', $post->ID ) ) : ?> + <?php if ( !empty($comment->comment_author_email) ): ?> + <?php comment_author_email_link() ?> | + <?php endif; ?> + <a href="edit-comments.php?s=<?php comment_author_IP() ?>&mode=detail"><?php comment_author_IP() ?></a> + <?php endif; //current_user_can?> + </p> + <?php if ( 'detail' == $mode ) comment_text(); ?> + <p><?php printf(__('From %1$s, %2$s'), $post_link, $ptime) ?></p> + </td> + <td><?php comment_date(__('Y/m/d')); ?></td> + <td class="action-links"> <?php + + $actions = array(); + + $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | '; + $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | '; + + // we're looking at list of only approved or only unapproved comments + if ( 'moderated' == $comment_status ) { + $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | '; + unset($actions['unapprove']); + } elseif ( 'approved' == $comment_status ) { + $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | '; + unset($actions['approve']); + } + + if ( current_user_can('edit_post', $comment->comment_post_ID) ) { + $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a> | '; + $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . '</a>'; + foreach ( $actions as $action => $link ) + echo "<span class='$action'>$link</span>"; + } + ?> + </td> + </tr> + <?php } function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { - global $wpdb; if (!$categories ) $categories = get_categories( 'hide_empty=0' ); @@ -323,10 +718,9 @@ function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $le } function list_meta( $meta ) { - global $post_ID; // Exit if no meta if (!$meta ) { - echo '<tbody id="the-list"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS + echo '<tbody id="the-list" class="list:meta"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS return; } $count = 0; @@ -338,43 +732,53 @@ function list_meta( $meta ) { <th colspan='2'><?php _e( 'Action' ) ?></th> </tr> </thead> + <tbody id='the-list' class='list:meta'> <?php - $r ="\n\t<tbody id='the-list'>"; - foreach ( $meta as $entry ) { - ++ $count; - if ( $count % 2 ) - $style = 'alternate'; - else - $style = ''; - if ('_' == $entry['meta_key'] { 0 } ) - $style .= ' hidden'; - - if ( is_serialized( $entry['meta_value'] ) ) { - if ( is_serialized_string( $entry['meta_value'] ) ) { - // this is a serialized string, so we should display it - $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); - } else { - // this is a serialized array/object so we should NOT display it - --$count; - continue; - } - } + foreach ( $meta as $entry ) + echo _list_meta_row( $entry, $count ); + echo "\n\t</tbody>"; +} + +function _list_meta_row( $entry, &$count ) { + static $update_nonce = false; + if ( !$update_nonce ) + $update_nonce = wp_create_nonce( 'add-meta' ); - $key_js = js_escape( $entry['meta_key'] ); - $entry['meta_key'] = attribute_escape($entry['meta_key']); - $entry['meta_value'] = attribute_escape($entry['meta_value']); - $entry['meta_id'] = (int) $entry['meta_id']; - $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; - $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>"; - $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; - $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__( 'Update' ))."' /><br />"; - $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; - $r .= js_escape(sprintf( __("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop." ), $key_js ) ); - $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' /></td>"; - $r .= "\n\t</tr>"; + $r = ''; + ++ $count; + if ( $count % 2 ) + $style = 'alternate'; + else + $style = ''; + if ('_' == $entry['meta_key'] { 0 } ) + $style .= ' hidden'; + + if ( is_serialized( $entry['meta_value'] ) ) { + if ( is_serialized_string( $entry['meta_value'] ) ) { + // this is a serialized string, so we should display it + $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); + } else { + // this is a serialized array/object so we should NOT display it + --$count; + return; + } } - echo $r; - echo "\n\t</tbody>"; + + $entry['meta_key'] = attribute_escape($entry['meta_key']); + $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea /> + $entry['meta_id'] = (int) $entry['meta_id']; + + $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); + + $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; + $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>"; + $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; + $r .= "\n\t\t<td style='text-align: center;'><input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /><br />"; + $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' "; + $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />"; + $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); + $r .= "</td>\n\t</tr>"; + return $r; } function meta_form() { @@ -390,14 +794,14 @@ function meta_form() { if ( $keys ) natcasesort($keys); ?> -<h3><?php _e( 'Add a new custom field:' ) ?></h3> +<p><strong><?php _e( 'Add a new custom field:' ) ?></strong></p> <table id="newmeta" cellspacing="3" cellpadding="3"> <tr> <th colspan="2"><?php _e( 'Key' ) ?></th> <th><?php _e( 'Value' ) ?></th> </tr> <tr valign="top"> - <td align="right" width="18%"> + <td style="width: 18%;" class="textright"> <?php if ( $keys ) : ?> <select id="metakeyselect" name="metakeyselect" tabindex="7"> <option value="#NONE#"><?php _e( '- Select -' ); ?></option> @@ -414,9 +818,11 @@ function meta_form() { <td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td> <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td> </tr> - +<tr class="submit"><td colspan="3"> + <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?> + <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta::post_id=<?php echo $GLOBALS['post_ID'] ? $GLOBALS['post_ID'] : $GLOBALS['temp_ID']; ?>" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" /> +</td></tr> </table> -<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field »' ) ?>" /></p> <?php } @@ -426,12 +832,12 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) { if ( $for_post ) $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; - + $tab_index_attribute = ''; if ( (int) $tab_index > 0 ) $tab_index_attribute = " tabindex=\"$tab_index\""; - echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>'; + // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); $post_date = ($for_post) ? $post->post_date : $comment->comment_date; @@ -442,28 +848,27 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) { $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); - echo "<select name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n"; + $month = "<select id=\"mm\" name=\"mm\"$tab_index_attribute>\n"; for ( $i = 1; $i < 13; $i = $i +1 ) { - echo "\t\t\t<option value=\"$i\""; + $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"'; if ( $i == $mm ) - echo ' selected="selected"'; - echo '>' . $wp_locale->get_month( $i ) . "</option>\n"; - } -?> -</select> -<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> -<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> @ -<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> : -<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> -<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> -<?php - if ( $edit ) { - printf( _c( 'Existing timestamp: %1$s %2$s, %3$s @ %4$s:%5$s|1: month, 2: month string, 3: full year, 4: hours, 5: minutes' ), $wp_locale->get_month( $mm ), $jj, $aa, $hh, $mn ); + $month .= ' selected="selected"'; + $month .= '>' . $wp_locale->get_month( $i ) . "</option>\n"; } + $month .= '</select>'; + + $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; + $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />'; + $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; + $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; + printf(_c('%1$s%2$s, %3$s <br />@ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute); + echo "\n\n"; + foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) + echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n"; ?> -</fieldset> - <?php +<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> +<?php } function page_template_dropdown( $default = '' ) { @@ -507,12 +912,12 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { function browse_happy() { $getit = __( 'WordPress recommends a better browser' ); echo ' - <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p> + <span id="bh" class="alignright"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></span> '; } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) - add_action( 'admin_footer', 'browse_happy' ); + add_action( 'in_admin_footer', 'browse_happy' ); function the_attachment_links( $id = false ) { $id = (int) $id; @@ -560,11 +965,13 @@ function the_attachment_links( $id = false ) { function wp_dropdown_roles( $default = false ) { global $wp_roles; $r = ''; - foreach( array_reverse($wp_roles->role_names) as $role => $name ) + foreach( $wp_roles->role_names as $role => $name ) { + $name = translate_with_context($name); if ( $default == $role ) // Make default first in list $p = "\n\t<option selected='selected' value='$role'>$name</option>"; else $r .= "\n\t<option value='$role'>$name</option>"; + } echo $p . $r; } @@ -588,10 +995,15 @@ function wp_convert_bytes_to_hr( $bytes ) { return $size . $units[$power]; } -function wp_import_upload_form( $action ) { +function wp_max_upload_size() { $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); - $bytes = apply_filters( 'import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); + $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); + return $bytes; +} + +function wp_import_upload_form( $action ) { + $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); $size = wp_convert_bytes_to_hr( $bytes ); ?> <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>"> @@ -603,7 +1015,7 @@ function wp_import_upload_form( $action ) { <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> </p> <p class="submit"> -<input type="submit" value="<?php _e( 'Upload file and import »' ); ?>" /> +<input type="submit" class="button" value="<?php _e( 'Upload file and import' ); ?>" /> </p> </form> <?php @@ -616,4 +1028,44 @@ function wp_remember_old_slug() { echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />'; } +/** + * add_meta_box() - Add a meta box to an edit form + * + * @since 2.5 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the meta box + * @param string $callback Function that fills the box with the desired content. The function should echo its output. + * @param string $page The type of edit page on which to show the box (post, page, link) + * @param string $context The context within the page where the boxes should show ('normal', 'advanced') + */ +function add_meta_box($id, $title, $callback, $page, $context = 'advanced') { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + $wp_meta_boxes[$page][$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback); +} + +function do_meta_boxes($page, $context, $object) { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) + return; + + foreach ( (array) $wp_meta_boxes[$page][$context] as $box ) { + echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n"; + echo "<h3>{$box['title']}</h3>\n"; + echo '<div class="inside">' . "\n"; + call_user_func($box['callback'], $object, $box); + echo "</div>\n"; + echo "</div>\n"; + } +} + ?> diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index bd39dea..7dae5be 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -14,6 +14,7 @@ function current_theme_info() { $ct->screenshot = $themes[$current_theme]['Screenshot']; $ct->description = $themes[$current_theme]['Description']; $ct->author = $themes[$current_theme]['Author']; + $ct->tags = $themes[$current_theme]['Tags']; return $ct; } diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index cbd0d4a..70d1441 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -1,8 +1,9 @@ <?php /* -// The admin side of our 1.0 update system -function core_update_footer( $msg ) { +// The admin side of our 1.1 update system + +function core_update_footer( $msg = '' ) { if ( !current_user_can('manage_options') ) return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] ); @@ -10,16 +11,18 @@ function core_update_footer( $msg ) { switch ( $cur->response ) { case 'development' : - return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' ); + return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], $cur->url, $cur->current ); break; case 'upgrade' : - return sprintf( '| <strong>'.__( 'Your WordPress %s is out of date. <a href="%s">Please update</a>.' ).'</strong>', $GLOBALS['wp_version'], $cur->url ); - break; + if ( current_user_can('manage_options') ) { + return sprintf( '| <strong>'.__( '<a href="%2$s">Get Version %3$s</a>' ).'</strong>', $GLOBALS['wp_version'], $cur->url, $cur->current ); + break; + } case 'latest' : default : - return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] ); + return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'], $cur->url, $cur->current ); break; } } @@ -32,14 +35,25 @@ function update_nag() { return false; if ( current_user_can('manage_options') ) - $msg = sprintf( __('A new version of WordPress is available! <a href="%s">Please update now</a>.'), $cur->url ); + $msg = sprintf( __('WordPress %2$s is available! <a href="%1$s">Please update now</a>.'), $cur->url, $cur->current ); else - $msg = __('A new version of WordPress is available! Please notify the site administrator.'); + $msg = sprintf( __('WordPress %2$s is available! Please notify the site administrator.'), $cur->url, $cur->current ); echo "<div id='update-nag'>$msg</div>"; } add_action( 'admin_notices', 'update_nag', 3 ); +// Called directly from dashboard +function update_right_now_message() { + $cur = get_option( 'update_core' ); + + $msg = sprintf( __('This is WordPress version %s.'), $GLOBALS['wp_version'] ); + if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') ) + $msg .= " <a href='$cur->url' class='rbutton'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>'; + + echo "<span id='wp-version-message'>$msg</span>"; +} + function wp_update_plugins() { global $wp_version; @@ -62,7 +76,7 @@ function wp_update_plugins() { continue; } - if ( $current->checked[ $file ] != $p['Version'] ) + if ( strval($current->checked[ $file ]) !== strval($p['Version']) ) $plugin_changed = true; } @@ -114,9 +128,123 @@ function wp_plugin_update_row( $file ) { $r = $current->response[ $file ]; echo "<tr><td colspan='5' class='plugin-update'>"; - printf( __('There is a new version of %s available. <a href="%s">Download version %s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version ); + if ( !current_user_can('edit_plugins') ) + printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version); + else if ( empty($r->package) ) + printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> <em>automatic upgrade unavailable for this plugin</em>.'), $plugin_data['Name'], $r->url, $r->new_version); + else + printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> or <a href="%4$s">upgrade automatically</a>.'), $plugin_data['Name'], $r->url, $r->new_version, wp_nonce_url("update.php?action=upgrade-plugin&plugin=$file", 'upgrade-plugin_' . $file) ); + echo "</td></tr>"; } add_action( 'after_plugin_row', 'wp_plugin_update_row' ); + +function wp_update_plugin($plugin, $feedback = '') { + global $wp_filesystem; + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + // Is an update available? + $current = get_option( 'update_plugins' ); + if ( !isset( $current->response[ $plugin ] ) ) + return new WP_Error('up_to_date', __('The plugin is at the latest version.')); + + // Is a filesystem accessor setup? + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) + WP_Filesystem(); + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); + + //Get the Base folder + $base = $wp_filesystem->get_base_dir(); + + if ( empty($base) ) + return new WP_Error('fs_nowordpress', __('Unable to locate WordPress directory.')); + + // Get the URL to the zip file + $r = $current->response[ $plugin ]; + + if ( empty($r->package) ) + return new WP_Error('no_package', __('Upgrade package not available.')); + + // Download the package + $package = $r->package; + apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); + $file = download_url($package); + + if ( is_wp_error($file) ) + return new WP_Error('download_failed', __('Download failed.'), $file->get_error_message()); + + $working_dir = $base . 'wp-content/upgrade/' . basename($plugin, '.php'); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + apply_filters('update_feedback', __('Unpacking the update')); + // Unzip package to working directory + $result = unzip_file($file, $working_dir); + if ( is_wp_error($result) ) { + unlink($file); + $wp_filesystem->delete($working_dir, true); + return $result; + } + + // Once extracted, delete the package + unlink($file); + + if ( is_plugin_active($plugin) ) { + //Deactivate the plugin silently, Prevent deactivation hooks from running. + apply_filters('update_feedback', __('Deactivating the plugin')); + deactivate_plugins($plugin, true); + } + + // Remove the existing plugin. + apply_filters('update_feedback', __('Removing the old version of the plugin')); + $plugin_dir = dirname($base . PLUGINDIR . "/$plugin"); + $plugin_dir = trailingslashit($plugin_dir); + + // If plugin is in its own directory, recursively delete the directory. + if ( strpos($plugin, '/') && $plugin_dir != $base . PLUGINDIR . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder + $deleted = $wp_filesystem->delete($plugin_dir, true); + else + $deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin"); + + if ( !$deleted ) { + $wp_filesystem->delete($working_dir, true); + return new WP_Error('delete_failed', __('Could not remove the old plugin')); + } + + apply_filters('update_feedback', __('Installing the latest version')); + // Copy new version of plugin into place. + if ( !copy_dir($working_dir, $base . PLUGINDIR) ) { + //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. + return new WP_Error('install_failed', __('Installation failed')); + } + + //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin + $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); + + // Remove working directory + $wp_filesystem->delete($working_dir, true); + + // Force refresh of plugin update information + delete_option('update_plugins'); + + if( empty($filelist) ) + return false; //We couldnt find any files in the working dir + + $folder = $filelist[0]; + $plugin = get_plugins('/' . $folder); //Pass it with a leading slash, search out the plugins in the folder, + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + return $folder . '/' . $pluginfiles[0]; //Pass it without a leading slash as WP requires +} + */ ?> diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 797e6e7..1cc9df9 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -6,7 +6,7 @@ require_once(ABSPATH . 'wp-admin/includes/admin.php'); require_once(ABSPATH . 'wp-admin/includes/schema.php'); if ( !function_exists('wp_install') ) : -function wp_install($blog_title, $user_name, $user_email, $public, $meta='') { +function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') { global $wp_rewrite; wp_check_mysql_version(); @@ -35,7 +35,7 @@ function wp_install($blog_title, $user_name, $user_email, $public, $meta='') { // being shared among blogs. Just set the role in that case. $user_id = username_exists($user_name); if ( !$user_id ) { - $random_password = substr(md5(uniqid(microtime())), 0, 6); + $random_password = wp_generate_password(); $user_id = wp_create_user($user_name, $random_password, $user_email); } else { $random_password = __('User already exists. Password inherited.'); @@ -105,7 +105,8 @@ function wp_install_defaults($user_id) { $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'))."')"); // First Page - $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')"); + $first_post_guid = get_option('home') . '/?page_id=2'; + $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')"); } endif; @@ -198,6 +199,9 @@ function upgrade_all() { if ( $wp_current_db_version < 6124 ) upgrade_230_old_tables(); + if ( $wp_current_db_version < 7499 ) + upgrade_250(); + maybe_disable_automattic_widgets(); $wp_rewrite->flush_rules(); @@ -724,6 +728,15 @@ function upgrade_old_slugs() { } +function upgrade_250() { + global $wp_current_db_version; + + if ( $wp_current_db_version < 6689 ) { + populate_roles_250(); + } + +} + // The functions we use to actually do stuff // General @@ -1253,12 +1266,10 @@ function translate_level_to_role($level) { } function wp_check_mysql_version() { - global $wp_version; - - // Make sure the server has MySQL 4.0 - $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info()); - if ( version_compare($mysql_version, '4.0.0', '<') ) - die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); + global $wpdb; + $result = $wpdb->check_database_version(); + if ( is_wp_error( $result ) ) + die( $result->get_error_message() ); } function maybe_disable_automattic_widgets() { diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index ca15057..e423465 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -73,6 +73,13 @@ function edit_user( $user_id = 0 ) { else $user->rich_editing = 'false'; + if ( !$update ) + $user->admin_color = 'fresh'; // Default to fresh for new users. + else if ( isset( $_POST['admin_color'] ) ) + $user->admin_color = $_POST['admin_color']; + else + $user->admin_color = 'fresh'; + $errors = new WP_Error(); /* checking that username has been typed */ @@ -82,37 +89,41 @@ function edit_user( $user_id = 0 ) { /* checking the password has been typed twice */ do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); - if (!$update ) { - if ( $pass1 == '' || $pass2 == '' ) - $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' )); + if ( $update ) { + if ( empty($pass1) && !empty($pass2) ) + $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) ); + elseif ( !empty($pass1) && empty($pass2) ) + $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) ); } else { - if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) ) - $errors->add( 'pass', __( "<strong>ERROR</strong>: you typed your new password only once." )); + if ( empty($pass1) ) + $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password.' ), array( 'form-field' => 'pass1' ) ); + elseif ( empty($pass2) ) + $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) ); } /* Check for "\" in password */ if( strpos( " ".$pass1, "\\" ) ) - $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' )); + $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); /* checking the password has been typed twice the same */ if ( $pass1 != $pass2 ) - $errors->add( 'pass', __( '<strong>ERROR</strong>: Please type the same password in the two password fields.' )); + $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) ); if (!empty ( $pass1 )) $user->user_pass = $pass1; if ( !$update && !validate_username( $user->user_login ) ) - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); + $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); if (!$update && username_exists( $user->user_login )) - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' )); + $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); /* checking e-mail address */ if ( empty ( $user->user_email ) ) { - $errors->add( 'user_email', __( "<strong>ERROR</strong>: please type an e-mail address" )); + $errors->add( 'user_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); } else if (!is_email( $user->user_email ) ) { - $errors->add( 'user_email', __( "<strong>ERROR</strong>: the email address isn't correct" )); + $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); } if ( $errors->get_error_codes() ) @@ -186,8 +197,6 @@ function get_nonauthor_user_ids() { function get_others_unpublished_posts($user_id, $type='any') { global $wpdb; - $user = get_userdata( $user_id ); - $level_key = $wpdb->prefix . 'user_level'; $editable = get_editable_user_ids( $user_id ); @@ -245,7 +254,6 @@ function wp_delete_user($id, $reassign = 'novalue') { global $wpdb; $id = (int) $id; - $user = get_userdata($id); if ($reassign == 'novalue') { $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); @@ -270,6 +278,7 @@ function wp_delete_user($id, $reassign = 'novalue') { wp_cache_delete($id, 'users'); wp_cache_delete($user->user_login, 'userlogins'); + wp_cache_delete($user->user_email, 'useremail'); return true; } @@ -281,4 +290,108 @@ function wp_revoke_user($id) { $user->remove_all_caps(); } +// WP_User_Search class +// by Mark Jaquith + +if ( !class_exists('WP_User_Search') ) : +class WP_User_Search { + var $results; + var $search_term; + var $page; + var $role; + var $raw_page; + var $users_per_page = 50; + var $first_user; + var $last_user; + var $query_limit; + var $query_sort; + var $query_from_where; + var $total_users_for_query = 0; + var $too_many_total_users = false; + var $search_errors; + + function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor + $this->search_term = $search_term; + $this->raw_page = ( '' == $page ) ? false : (int) $page; + $this->page = (int) ( '' == $page ) ? 1 : $page; + $this->role = $role; + + $this->prepare_query(); + $this->query(); + $this->prepare_vars_for_template_usage(); + $this->do_paging(); + } + + function prepare_query() { + global $wpdb; + $this->first_user = ($this->page - 1) * $this->users_per_page; + $this->query_limit = ' LIMIT ' . $this->first_user . ',' . $this->users_per_page; + $this->query_sort = ' ORDER BY user_login'; + $search_sql = ''; + if ( $this->search_term ) { + $searches = array(); + $search_sql = 'AND ('; + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) + $searches[] = $col . " LIKE '%$this->search_term%'"; + $search_sql .= implode(' OR ', $searches); + $search_sql .= ')'; + } + + $this->query_from_where = "FROM $wpdb->users"; + if ( $this->role ) + $this->query_from_where .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE '%$this->role%'"; + else + $this->query_from_where .= " WHERE 1=1"; + $this->query_from_where .= " $search_sql"; + + } + + function query() { + global $wpdb; + $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_sort . $this->query_limit); + + if ( $this->results ) + $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit + else + $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); + } + + function prepare_vars_for_template_usage() { + $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone + } + + function do_paging() { + if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results + $this->paging_text = paginate_links( array( + 'total' => ceil($this->total_users_for_query / $this->users_per_page), + 'current' => $this->page, + 'base' => 'users.php?%_%', + 'format' => 'userspage=%#%', + 'add_args' => array( 'usersearch' => urlencode($this->search_term) ) + ) ); + } + } + + function get_results() { + return (array) $this->results; + } + + function page_links() { + echo $this->paging_text; + } + + function results_are_paged() { + if ( $this->paging_text ) + return true; + return false; + } + + function is_search() { + if ( $this->search_term ) + return true; + return false; + } +} +endif; + ?> diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index 4523b24..bd425f9 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -2,7 +2,7 @@ // $_search is unsanitized function wp_list_widgets( $show = 'all', $_search = false ) { - global $wp_registered_widgets, $sidebars_widgets; + global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls; if ( $_search ) { // sanitize $search = preg_replace( '/[^\w\s]/', '', $_search ); @@ -52,17 +52,31 @@ function wp_list_widgets( $show = 'all', $_search = false ) { $widget_control_template = ob_get_contents(); ob_end_clean(); + $widget_id = $widget['id']; // save this for later in case we mess with $widget['id'] + $is_multi = false !== strpos( $widget_control_template, '%i%' ); if ( !$sidebar || $is_multi ) { - if ( $is_multi ) - $already_shown[] = $widget['callback']; // it's a multi-widget. We only need to show it in the list once. - $action = 'add'; - $add_url = wp_nonce_url( add_query_arg( array( + $add_query = array( 'sidebar' => $sidebar, - 'add' => $widget['id'], 'key' => false, 'edit' => false - ) ), "add-widget_$widget[id]" ); + ); + if ( $is_multi ) { + // it's a multi-widget. We only need to show it in the list once. + $already_shown[] = $widget['callback']; + $num = (int) array_pop( explode( '-', $widget['id'] ) ); + $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; + // so that we always add a new one when clicking "add" + while ( isset($wp_registered_widgets["$id_base-$num"]) ) + $num++; + $widget['id'] = "$id_base-$num"; + $add_query['base'] = $id_base; + $add_query['key'] = $num; + $add_query['sidebar'] = $GLOBALS['sidebar']; + } + $add_query['add'] = $widget['id']; + $action = 'add'; + $add_url = wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ); } else { $action = 'edit'; $edit_url = clean_url( add_query_arg( array( @@ -110,7 +124,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) { <?php endif; ?> <div class="widget-description"> - <?php echo ( $widget_description = wp_widget_description( $widget['id'] ) ) ? $widget_description : ' '; ?> + <?php echo ( $widget_description = wp_widget_description( $widget_id ) ) ? $widget_description : ' '; ?> </div> <br class="clear" /> @@ -174,7 +188,7 @@ function wp_widget_control( $sidebar_args ) { $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar - $edit = $edit_widget > 0 && $key && $edit_widget == $key; // (bool) are we currently editing this widget + $edit = -1 < $edit_widget && is_numeric($key) && $edit_widget === $key; // (bool) are we currently editing this widget $id_format = $widget['id']; // We aren't showing a widget control, we're outputing a template for a mult-widget control @@ -198,12 +212,11 @@ function wp_widget_control( $sidebar_args ) { $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; unset($wp_registered_widgets[$widget_id]['_callback']); - if ( $widget_title ) - $widget_title = sprintf( _c('%1$s: %2$s|widget_admin_title' ), $sidebar_args['widget_name'], $widget_title ); + if ( $widget_title && $widget_title != $control['name'] ) + $widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title ); else $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); - if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] ) echo $sidebar_args['before_widget']; ?> @@ -241,7 +254,7 @@ function wp_widget_control( $sidebar_args ) { <?php endif; ?> - <a class="widget-action widget-control-remove delete alignright" href="<?php echo clean_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key ), wp_nonce_url( null, "remove-widget_$widget[id]" ) ) ); ?>"><?php _e('Remove'); ?></a> + <a class="widget-action widget-control-remove delete alignright" href="<?php echo clean_url( wp_nonce_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key ) ), "remove-widget_$widget[id]" ) ); ?>"><?php _e('Remove'); ?></a> <br class="clear" /> </div> </div> diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php index a516f8b..3b77d10 100644 --- a/wp-admin/index-extra.php +++ b/wp-admin/index-extra.php @@ -1,5 +1,6 @@ <?php require_once('admin.php'); +require( 'includes/dashboard.php' ); require_once (ABSPATH . WPINC . '/rss.php'); @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); @@ -7,67 +8,21 @@ require_once (ABSPATH . WPINC . '/rss.php'); switch ( $_GET['jax'] ) { case 'incominglinks' : - -$rss_feed = apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ); -$more_link = apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ); - -$rss = @fetch_rss( $rss_feed ); -if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results -?> -<h3><?php _e('Incoming Links'); ?> <cite><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('More »'); ?></a></cite></h3> -<ul> -<?php -$rss->items = array_slice($rss->items, 0, 10); -foreach ($rss->items as $item ) { -?> - <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wptexturize(wp_specialchars($item['title'])); ?></a></li> -<?php } ?> -</ul> -<?php -} -break; + wp_dashboard_incoming_links_output(); + break; case 'devnews' : -$rss = @fetch_rss(apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' )); -if ( isset($rss->items) && 0 != count($rss->items) ) { -?> -<h3><?php echo apply_filters( 'dashboard_primary_title', __('WordPress Development Blog') ); ?></h3> -<?php -$rss->items = array_slice($rss->items, 0, 3); -foreach ($rss->items as $item ) { -?> -<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> — <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4> -<p><?php echo $item['description']; ?></p> -<?php - } -} -?> - -<?php -break; + wp_dashboard_rss_output( 'dashboard_primary' ); + break; case 'planetnews' : -$rss = @fetch_rss(apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' )); -if ( isset($rss->items) && 0 != count($rss->items) ) { -?> -<h3><?php echo apply_filters( 'dashboard_secondary_title', __('Other WordPress News') ); ?></h3> -<ul> -<?php -$rss->items = array_slice($rss->items, 0, 20); -foreach ($rss->items as $item ) { -$title = wp_specialchars($item['title']); -$author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] ); -$post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] ); -?> -<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><span class="post"><?php echo $post; ?></span><span class="hidden"> - </span><cite><?php echo $author; ?></cite></a></li> -<?php - } -?> -</ul> -<p class="readmore"><a href="<?php echo apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ); ?>"><?php _e('Read more »'); ?></a></p> -<?php -} -break; + wp_dashboard_secondary_output(); + break; + +case 'plugins' : + wp_dashboard_plugins_output(); + break; + } ?> diff --git a/wp-admin/index.php b/wp-admin/index.php index 2447e2f..32a2d47 100644 --- a/wp-admin/index.php +++ b/wp-admin/index.php @@ -1,19 +1,30 @@ <?php + require_once('admin.php'); +require_once(ABSPATH . 'wp-admin/includes/dashboard.php'); + +wp_dashboard_setup(); + function index_js() { ?> <script type="text/javascript"> jQuery(function() { - jQuery('#incominglinks').load('index-extra.php?jax=incominglinks'); - jQuery('#devnews').load('index-extra.php?jax=devnews'); - jQuery('#planetnews').load('index-extra.php?jax=planetnews'); + jQuery('#dashboard_incoming_links div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=incominglinks'); + jQuery('#dashboard_primary div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=devnews'); + jQuery('#dashboard_secondary div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=planetnews'); + jQuery('#dashboard_plugins div.dashboard-widget-content').not( '.dashboard-widget-control' ).find( '.widget-loading' ).parent().load('index-extra.php?jax=plugins'); }); </script> <?php } add_action( 'admin_head', 'index_js' ); +function index_css() { + wp_admin_css( 'css/dashboard' ); +} +add_action( 'admin_head', 'index_css' ); + wp_enqueue_script( 'jquery' ); $title = __('Dashboard'); @@ -25,121 +36,94 @@ $today = current_time('mysql', 1); <div class="wrap"> -<h2><?php _e('Welcome to WordPress'); ?></h2> +<h2><?php _e('Dashboard'); ?></h2> -<div id="zeitgeist"> -<h2><?php _e('Latest Activity'); ?></h2> +<div id="rightnow"> +<h3 class="reallynow"> + <span><?php _e('Right Now'); ?></span> -<div id="incominglinks"></div> +<?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?> + <a href="post-new.php" class="rbutton"><strong><?php _e('Write a New Post'); ?></strong></a> +<?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?> + <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a> +<?php endif; ?> + <br class="clear" /> +</h3> <?php -$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5"); -$numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); +$num_posts = wp_count_posts( 'post' ); +$num_pages = wp_count_posts( 'page' ); -if ( $comments || $numcomments ) : -?> -<div> -<h3><?php printf( __( 'Comments <a href="%s" title="More comments…">»</a>' ), 'edit-comments.php' ); ?></h3> +$num_cats = wp_count_terms('category'); -<?php if ( $numcomments ) : ?> -<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s) »'), number_format_i18n($numcomments) ); ?></a></strong></p> -<?php endif; ?> +$num_tags = wp_count_terms('post_tag'); -<ul> -<?php -if ( $comments ) { -foreach ($comments as $comment) { - echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>'); - edit_comment_link(__("Edit"), ' <small>(', ')</small>'); - echo '</li>'; +$post_type_texts = array(); + +if ( !empty($num_posts->publish) ) { // with feeds, anyone can tell how many posts there are. Just unlink if !current_user_can + $post_text = sprintf( __ngettext( '%s post', '%s posts', $num_posts->publish ), number_format_i18n( $num_posts->publish ) ); + $post_type_texts[] = $can_edit_posts ? "<a href='edit.php'>$post_text</a>" : $post_text; } +if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can + $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>'; +} +if ( $can_edit_posts && !empty($num_posts->draft) ) { + $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>'; +} +if ( $can_edit_posts && !empty($num_posts->future) ) { + $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>'; } -?> -</ul> -</div> -<?php endif; ?> -<?php -if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) : -?> -<div> -<h3><?php printf( __( 'Posts <a href="%s" title="More posts…">»</a>' ), 'edit.php' ); ?></h3> -<ul> -<?php -foreach ($recentposts as $post) { - if ($post->post_title == '') - $post->post_title = sprintf(__('Post #%s'), $post->ID); - echo "<li><a href='post.php?action=edit&post=$post->ID'>"; - the_title(); - echo '</a></li>'; +if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) { + $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) ); +} else { + $pending_text = ''; } -?> -</ul> -</div> -<?php endif; ?> -<?php -if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future' ORDER BY post_date ASC") ) : -?> -<div> -<h3><?php _e('Scheduled Entries:') ?></h3> -<ul> -<?php -foreach ($scheduled as $post) { - if ($post->post_title == '') - $post->post_title = sprintf(__('Post #%s'), $post->ID); - echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "</li>"; +$cats_text = sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) ); +$tags_text = sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) ); +if ( current_user_can( 'manage_categories' ) ) { + $cats_text = "<a href='categories.php'>$cats_text</a>"; + $tags_text = "<a href='edit-tags.php'>$tags_text</a>"; } -?> -</ul> -</div> -<?php endif; ?> -<div> -<h3><?php _e('Blog Stats'); ?></h3> +$post_type_text = implode(', ', $post_type_texts); + +// There is always a category +$sentence = sprintf( __( 'You have %1$s, contained within %2$s and %3$s. %4$s' ), $post_type_text, $cats_text, $tags_text, $pending_text ); +$sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text ); + +?> +<p class="youhave"><?php echo $sentence; ?></p> <?php -$numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); -$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); -$numcats = wp_count_terms('category'); -$numtags = wp_count_terms('post_tag'); - -$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php'); -$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format_i18n($numcomms), 'edit-comments.php'); -$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format_i18n($numcats), 'categories.php'); -$tag_str = sprintf(__ngettext('%1$s tag', '%1$s tags', $numtags), number_format_i18n($numtags)); +$ct = current_theme_info(); +$sidebars_widgets = wp_get_sidebars_widgets(); +$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ) ); +$widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets ); +if ( $can_switch_themes = current_user_can( 'switch_themes' ) ) + $widgets_text = "<a href='widgets.php'>$widgets_text</a>"; ?> +<p class="youare"> + <?php printf( __( 'You are using %1$s theme with %2$s.' ), $ct->title, $widgets_text ); ?> + <?php if ( $can_switch_themes ) : ?> + <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a> + <?php endif; ?> + <?php //update_right_now_message(); ?> +</p> -<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s and %4$s.'), $post_str, $comm_str, $cat_str, $tag_str); ?></p> -</div> +<?php do_action( 'rightnow_end' ); ?> +<?php do_action( 'activity_box_end' ); ?> +</div><!-- rightnow --> -<?php do_action('activity_box_end'); ?> -</div> +<br class="clear" /> -<p><?php _e('Use these links to get started:'); ?></p> +<div id="dashboard-widgets-wrap"> -<ul> -<?php if ( current_user_can('edit_posts') ) : ?> - <li><a href="post-new.php"><?php _e('Write a post'); ?></a></li> -<?php endif; ?> - <li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li> -<?php if ( current_user_can('manage_links') ) : ?> - <li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li> -<?php endif; ?> -<?php if ( current_user_can('switch_themes') ) : ?> - <li><a href="themes.php"><?php _e('Change your site’s look or theme'); ?></a></li> -<?php endif; ?> -</ul> -<p><?php _e("Need help with WordPress? Please see our <a href='http://codex.wordpress.org/'>documentation</a> or visit the <a href='http://wordpress.org/support/'>support forums</a>."); ?></p> +<?php wp_dashboard(); ?> -<div id="devnews"></div> -<div id="planetnews"></div> +</div><!-- dashboard-widgets-wrap --> -<div style="clear: both"> -<br clear="all" /> -</div> -</div> +</div><!-- wrap --> -<?php -require('./admin-footer.php'); -?> +<?php require('./admin-footer.php'); ?> diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php index b53376e..d124b1a 100644 --- a/wp-admin/install-helper.php +++ b/wp-admin/install-helper.php @@ -16,7 +16,7 @@ function maybe_create_table($table_name, $create_ddl) { } } //didn't find it try to create it. - $q = $wpdb->query($create_ddl); + $wpdb->query($create_ddl); // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { if ($table == $table_name) { @@ -41,7 +41,7 @@ function maybe_add_column($table_name, $column_name, $create_ddl) { } } //didn't find it try to create it. - $q = $wpdb->query($create_ddl); + $wpdb->query($create_ddl); // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { if ($column == $column_name) { @@ -63,7 +63,7 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) { foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { if ($column == $column_name) { //found it try to drop it. - $q = $wpdb->query($drop_ddl); + $wpdb->query($drop_ddl); // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { if ($column == $column_name) { diff --git a/wp-admin/js/blog-switch.js b/wp-admin/js/blog-switch.js new file mode 100644 index 0000000..19cf9ef --- /dev/null +++ b/wp-admin/js/blog-switch.js @@ -0,0 +1,15 @@ +jQuery( function($) { + var form = $( '#all-my-blogs' ).submit( function() { document.location = form.find( 'select' ).val(); return false;} ); + var tab = $('#all-my-blogs-tab a'); + var head = $('#wphead'); + $('.blog-picker-toggle').click( function() { + form.toggle(); + tab.toggleClass( 'current' ); + if ( form.is( ':visible' ) ) { + head.css( 'padding-top', form.height() + 16 ); + } else { + head.css( 'padding-top', 0 ); + } + return false; + } ); +} ); diff --git a/wp-admin/js/cat.js b/wp-admin/js/cat.js index e697e9b..4a64994 100644 --- a/wp-admin/js/cat.js +++ b/wp-admin/js/cat.js @@ -1,11 +1,5 @@ -addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;}); -addLoadEvent(newCatAddIn); -function newCatAddIn() { - var jaxcat = $('jaxcat'); - if ( !jaxcat ) - return false; - // These multiple blank hidden inputs are needed: https://bugzilla.mozilla.org/show_bug.cgi?id=377815 , #3895 , #4664 - Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span>'); - $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); }; - $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); }; -} +jQuery( function($) { + var myConfirm = function() { return '' !== $('#newcat').val(); }; + $('#jaxcat').prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" class="add:categorychecklist:jaxcat" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span><span id="cat-ajax-response"></span>') + $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); +} ); diff --git a/wp-admin/js/categories.js b/wp-admin/js/categories.js index 3cee6c6..a327338 100644 --- a/wp-admin/js/categories.js +++ b/wp-admin/js/categories.js @@ -1,16 +1,23 @@ -addLoadEvent(function() { - if (!theList.theList) return false; - document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; - theList.addComplete = function(what, where, update, transport) { - var name = getNodeValue(transport.responseXML, 'name').unescapeHTML(); - var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id'); - var options = document.forms['addcat'].category_parent.options; +jQuery(function($) { + var options = false + if ( document.forms['addcat'].category_parent ) + options = document.forms['addcat'].category_parent.options; + + var addAfter = function( r, settings ) { + var name = $("<span>" + $('name', r).text() + "</span>").html(); + var id = $('cat', r).attr('id'); options[options.length] = new Option(name, id); - }; - theList.delComplete = function(what, id) { - var options = document.forms['addcat'].category_parent.options; + } + + var delAfter = function( r, settings ) { + var id = $('cat', r).attr('id'); for ( var o = 0; o < options.length; o++ ) if ( id == options[o].value ) options[o] = null; - }; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList(); }); diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index bde9b97..3efdf11 100644 --- a/wp-admin/js/comment.js +++ b/wp-admin/js/comment.js @@ -1,12 +1,26 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { add_postbox_toggles('comment'); + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(commentL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(commentL10n.edit); } return false; }); -});
\ No newline at end of file +}); diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 9f05e55..6559d7d 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -1,4 +1,4 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { // pulse jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); @@ -7,6 +7,39 @@ addLoadEvent( function() { // Basic form validation if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) { - jQuery('form').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); + jQuery('form.validate').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); } }); + +(function(JQ) { + JQ.fn.tTips = function() { + + JQ('body').append('<div id="tTips"><p id="tTips_inside"></p></div>'); + var TT = JQ('#tTips'); + + this.each(function() { + var el = JQ(this), txt; + + if ( txt = el.attr('title') ) el.attr('tip', txt).removeAttr('title'); + else return; + el.find('img').removeAttr('alt'); + + el.mouseover(function(e) { + txt = el.attr('tip'), o = el.offset();; + + clearTimeout(TT.sD); + TT.find('p').html(txt); + + TT.css({'top': o.top - 43, 'left': o.left - 5}); + TT.sD = setTimeout(function(){TT.fadeIn(150);}, 100); + }); + + el.mouseout(function() { + clearTimeout(TT.sD); + TT.css({display : 'none'}); + }) + }); + } +}(jQuery)); + +jQuery(function(){jQuery('#media-buttons a').tTips();}); diff --git a/wp-admin/js/custom-fields.js b/wp-admin/js/custom-fields.js index ad7a2db..8f2b1a5 100644 --- a/wp-admin/js/custom-fields.js +++ b/wp-admin/js/custom-fields.js @@ -1,26 +1,33 @@ -function customFieldsOnComplete( what, where, update, transport ) { - var pidEl = $('post_ID'); - pidEl.name = 'post_ID'; - pidEl.value = getNodeValue(transport.responseXML, 'postid'); - var aEl = $('hiddenaction') - if ( aEl.value == 'post' ) aEl.value = 'postajaxpost'; -} -addLoadEvent(customFieldsAddIn); -function customFieldsAddIn() { - theList.showLink=0; - theList.addComplete = customFieldsOnComplete; - 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); }; - } +jQuery( function($) { + var before = function() { + var nonce = $('#newmeta [@name=_ajax_nonce]').val(); + var postId = $('#post_ID').val(); + if ( !nonce || !postId ) { return false; } + return [nonce,postId]; } - $('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); }; - $('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); }; -} + var addBefore = function( s ) { + var b = before(); + if ( !b ) { return false; } + s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1]; + return s; + }; + + var addAfter = function( r, s ) { + var postId = $('postid', r).text(); + if ( !postId ) { return; } + $('#post_ID').attr( 'name', 'post_ID' ).val( postId ); + var h = $('#hiddenaction'); + if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); } + }; + + var delBefore = function( s ) { + var b = before(); if ( !b ) return false; + s.data._ajax_nonce = b[0]; s.data.post_id = b[1]; + return s; + } + + $('#the-list') + .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } ) + .find('.updatemeta, .deletemeta').attr( 'type', 'button' ); +} ); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index e1fc68f..f2bf8f8 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -1,59 +1,70 @@ -addLoadEvent(function() { - theCommentList = new listMan('the-comment-list'); - if ( !theCommentList ) - return false; +var theList; var theExtraList; +jQuery(function($) { - theExtraCommentList = new listMan('the-extra-comment-list'); - if ( theExtraCommentList ) { - theExtraCommentList.showLink = 0; - theExtraCommentList.altOffset = 1; - if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes ) - var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; - else - var commentNum = 0; - var urlQ = document.location.href.split('?'); - var params = urlQ[1] ? urlQ[1].toQueryParams() : []; - var search = params['s'] ? params['s'] : ''; - var page = params['apage'] ? params['apage'] : 1; - } - - theCommentList.dimComplete = function(what,id,dimClass) { - var m = document.getElementById('awaitmod'); - if ( document.getElementById(what + '-' + id).className.match(dimClass) ) - m.innerHTML = parseInt(m.innerHTML,10) + 1; - else - m.innerHTML = parseInt(m.innerHTML,10) - 1; - } +var dimAfter = function( r, settings ) { + $('li span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + var t = parseInt(a.parent().attr('title'), 10); + if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment + n = n - 1; + t = t + 1; + } else { // we approved a formerly unapproved comment + n = n + 1; + t = t - 1; + } + if ( n < 0 ) { n = 0; } + if ( t < 0 ) { t = 0; } + if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); } + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + a.html( n.toString() ); + }); +} - theCommentList.delComplete = function(what,id) { - var m = document.getElementById('awaitmod'); - what = what.split('-')[0]; - if ( document.getElementById(what + '-' + id).className.match('unapproved') ) - m.innerHTML = parseInt(m.innerHTML,10) - 1; - if ( theExtraCommentList && commentNum ) { - var theMover = theExtraCommentList.theList.childNodes[0]; - Element.removeClassName(theMover,'alternate'); - theCommentList.theList.appendChild(theMover); - theExtraCommentList.inputData += '&page=' + page; - if ( search ) - theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box - theExtraCommentList.addComplete = function() { - if ( theExtraCommentList.theList.childNodes ) - var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; - else - var commentNum = 0; - } - theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request +var delAfter = function( r, settings ) { + $('li span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + n = n - 1; + } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" + n = n + 1; } + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + var t = parseInt(a.parent().attr('title'), 10); + if ( t < 1 ) { return; } + t = t - 1; + a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + return; + } + var n = parseInt(a.html(),10) - 1; + a.html( n.toString() ); + }); + + if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { + return; } - if ( theList ) // the post list: edit.php - theList.delComplete = function() { - var comments = document.getElementById('comments'); - var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments); - var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList); - setTimeout(commdel,705); - setTimeout(listdel,705); - } -}); + theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); + $('#get-extra-comments').submit(); +} + +theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); +theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ); +} ); diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js index a5500ec..757fd30 100644 --- a/wp-admin/js/editor.js +++ b/wp-admin/js/editor.js @@ -24,36 +24,45 @@ switchEditors = { }, pre_wpautop : function(content) { - // We have a TON of cleanup to do. + // We have a TON of cleanup to do. Line breaks are already stripped. - // Remove anonymous, empty paragraphs. - content = content.replace(new RegExp('<p>(\\s| |<br />)*</p>', 'mg'), ''); + // Pretty it up for the source editor + var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|pre|p'; + content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); // Mark </p> if it has any attributes. - content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>'); + content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>'); - // Get it ready for wpautop. + // Sepatate <div> containing <p> + content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n'); + + // Remove <p> and <br /> content = content.replace(new RegExp('\\s*<p>', 'mgi'), ''); content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n'); // Fix some block element newline issues - var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; - content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n'); - content = content.replace(new RegExp('<li>', 'g'), '\t<li>'); + content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div'); + content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n'); + + var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; + content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n'); + content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>'); if ( content.indexOf('<object') != -1 ) { - content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'g'), "<param$1>"); // no pee inside object/embed - content = content.replace(new RegExp('\\s*</embed>\\s*', 'g'), '</embed>'); + content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>"); + content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>'); } // Unmark special paragraph closing tags content = content.replace(new RegExp('</p#>', 'g'), '</p>\n'); - content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1'); + content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1'); - // Trim trailing whitespace + // Trim whitespace + content = content.replace(new RegExp('^\\s*', ''), ''); content = content.replace(new RegExp('\\s*$', ''), ''); // Hope. diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js index 21a62f4..6cb2cb7 100644 --- a/wp-admin/js/forms.js +++ b/wp-admin/js/forms.js @@ -1,10 +1,10 @@ function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { - if(form.elements[i].type == "checkbox" && !(form.elements[i].hasAttribute('onclick'))) { - if(form.elements[i].checked == true) - form.elements[i].checked = false; - else - form.elements[i].checked = true; + if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) { + if(form.elements[i].checked == true) + form.elements[i].checked = false; + else + form.elements[i].checked = true; } } } @@ -28,4 +28,4 @@ function checkAllUsers(role) { inp.checked = true; else inp.checked = false; -}
\ No newline at end of file +} diff --git a/wp-admin/js/link.js b/wp-admin/js/link.js index 9f5a28d..cfc0f94 100644 --- a/wp-admin/js/link.js +++ b/wp-admin/js/link.js @@ -1,4 +1,4 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { jQuery('#link_name').focus(); // postboxes add_postbox_toggles('link'); diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index 02fd708..0060e8e 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -1,16 +1,32 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { add_postbox_toggles('page'); make_slugedit_clickable(); + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + // hide advanced slug field jQuery('#pageslugdiv').hide(); jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(postL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(postL10n.edit); } return false; }); -});
\ No newline at end of file +}); diff --git a/wp-admin/js/password-strength-meter.js b/wp-admin/js/password-strength-meter.js index eba43fc..e90c3e0 100644 --- a/wp-admin/js/password-strength-meter.js +++ b/wp-admin/js/password-strength-meter.js @@ -3,15 +3,13 @@ // Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com // for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/ -var shortPass = 'Too short' -var badPass = 'Bad' -var goodPass = 'Good' -var strongPass = 'Strong' +var shortPass = pwsL10n.short +var badPass = pwsL10n.bad +var goodPass = pwsL10n.good +var strongPass = pwsL10n.strong - -function passwordStrength(password,username) -{ +function passwordStrength(password,username) { score = 0 //password < 4 @@ -79,84 +77,4 @@ function checkRepetition(pLen,str) { } return res } -// Password strength meter -// This jQuery plugin is written by firas kassem [2007.04.05] -// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com -// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/ - -var shortPass = 'Too short' -var badPass = 'Bad' -var goodPass = 'Good' -var strongPass = 'Strong' - - - -function passwordStrength(password,username) -{ - score = 0 - - //password < 4 - if (password.length < 4 ) { return shortPass } - - //password == username - if (password.toLowerCase()==username.toLowerCase()) return badPass - - //password length - score += password.length * 4 - score += ( checkRepetition(1,password).length - password.length ) * 1 - score += ( checkRepetition(2,password).length - password.length ) * 1 - score += ( checkRepetition(3,password).length - password.length ) * 1 - score += ( checkRepetition(4,password).length - password.length ) * 1 - - //password has 3 numbers - if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5 - - //password has 2 sybols - if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5 - - //password has Upper and Lower chars - if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10 - - //password has number and chars - if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15 - // - //password has number and symbol - if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15 - //password has char and symbol - if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15 - - //password is just a nubers or chars - if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10 - - //verifing 0 < score < 100 - if ( score < 0 ) score = 0 - if ( score > 100 ) score = 100 - - if (score < 34 ) return badPass - if (score < 68 ) return goodPass - return strongPass -} - - -// checkRepetition(1,'aaaaaaabcbc') = 'abcbc' -// checkRepetition(2,'aaaaaaabcbc') = 'aabc' -// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd' - -function checkRepetition(pLen,str) { - res = "" - for ( i=0; i<str.length ; i++ ) { - repeated=true - for (j=0;j < pLen && (j+i+pLen) < str.length;j++) - repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen)) - if (j<pLen) repeated=false - if (repeated) { - i+=pLen-1 - repeated=false - } - else { - res+=str.charAt(i) - } - } - return res -} diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 9aeafcc..78b22ed 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -58,15 +58,17 @@ function tag_press_key( e ) { } } -addLoadEvent( function() { +jQuery(document).ready( function() { + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + // postboxes add_postbox_toggles('post'); - // If no tags on the page, skip the tag and category stuff. - if ( !jQuery('#tags-input').size() ) { - return; - } - // Editable slugs make_slugedit_clickable(); @@ -76,7 +78,7 @@ addLoadEvent( function() { jQuery('#tags-input').hide(); tag_update_quickclicks(); // add the quickadd form - jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); + jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); jQuery('#tagadd').click( tag_flush_to_text ); jQuery('#newtag').focus(function() { if ( this.value == postL10n.addTag ) @@ -91,6 +93,8 @@ addLoadEvent( function() { jQuery('#publish').click( tag_save_on_publish ); jQuery('#save-post').click( tag_save_on_publish ); + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + // auto-suggest stuff jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); jQuery('#newtag').keypress( tag_press_key ); @@ -149,9 +153,24 @@ addLoadEvent( function() { jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(postL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(postL10n.edit); } return false; - }); + + }); + + // Custom Fields + jQuery('#the-list').wpList( { addAfter: function( xml, s ) { + if ( jQuery.isFunction( autosave_update_post_ID ) ) { + autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); + } + } }); }); diff --git a/wp-admin/js/upload.js b/wp-admin/js/upload.js index d38cdcb..f60f113 100644 --- a/wp-admin/js/upload.js +++ b/wp-admin/js/upload.js @@ -1,21 +1,51 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { theFileList = { currentImage: {ID: 0}, nonce: '', tab: '', postID: 0, - toQueryParams: function(qryStrOrig) { - var params = new Object(); - var qryStr = qryStrOrig; - var i = 0; - do { - params[qryStr.split("=")[0].replace(/&/, "")] = ( qryStr.split("=")[1] ) ? qryStr.split("=")[1].split(/&|$/)[0] : ''; - qryStr = ( qryStr.split("=")[1] ) ? qryStr.split(qryStr.split("=")[1].split(/&|$/)[0])[1] : ''; - i++; - } - while(i < (qryStrOrig.split("=").length - 1)); - return params; + // cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html + createCookie: function(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; + }, + + readCookie: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + assignCookieOnChange: function() { + jQuery(this).bind("change", function(){ + theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365); + }); + }, + + checkCookieSetting: function(name, defaultSetting) { + return this.readCookie(name) ? this.readCookie(name) : defaultSetting; + }, + + toQueryParams: function( s ) { + var r = {}; if ( !s ) { return r; } + var q = s.split('?'); if ( q[1] ) { s = q[1]; } + var pp = s.split('&'); + for ( var i in pp ) { + var p = pp[i].split('='); + r[p[0]] = p[1]; + } + return r; }, toQueryString: function(params) { @@ -116,12 +146,12 @@ addLoadEvent( function() { h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>"; h += "<table>"; var display = []; - var checked = 'display-title'; + var checkedDisplay = 'display-title'; if ( 1 == this.currentImage.isImage ) { - checked = 'display-full'; + checkedDisplay = 'display-full'; if ( this.currentImage.thumb ) { display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.thumb + "</label><br />"); - checked = 'display-thumb'; + checkedDisplay = 'display-thumb'; } display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> " + this.full + "</label>"); } else if ( this.currentImage.thumb ) { @@ -134,9 +164,9 @@ addLoadEvent( function() { h += "</td></tr>"; } - h += "<tr><th>" + this.link + "</th><td>"; - h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> " + this.file + "</label><br />"; - h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />"; + var checkedLink = 'link-file'; + h += "<tr><th>" + this.link + "</th><td>"; + h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' /> " + this.file + "</label><br />"; h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />"; h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> " + this.none + "</label>"; h += "</td></tr>"; @@ -148,7 +178,12 @@ addLoadEvent( function() { h += "</div>"; jQuery(h).prependTo('#upload-content'); - jQuery('#' + checked).attr('checked','checked'); + jQuery("input[@name='display']").each(theFileList.assignCookieOnChange); + jQuery("input[@name='link']").each(theFileList.assignCookieOnChange); + checkedDisplay = this.checkCookieSetting('display', checkedDisplay); + checkedLink = this.checkCookieSetting('link', checkedLink); + jQuery('#' + checkedDisplay).attr('checked','checked'); + jQuery('#' + checkedLink).attr('checked','checked'); if (e) return e.stopPropagation(); return false; }, @@ -288,7 +323,7 @@ addLoadEvent( function() { }; - for ( var property in uploadL10n ) + for ( var property in uploadL10n ) theFileList[property] = uploadL10n[property]; theFileList.initializeVars(); theFileList.initializeLinks(); diff --git a/wp-admin/js/users.js b/wp-admin/js/users.js index f249f65..522cbad 100644 --- a/wp-admin/js/users.js +++ b/wp-admin/js/users.js @@ -1,21 +1 @@ -addLoadEvent(function() { - theListEls = document.getElementsByTagName('tbody'); - theUserLists = new Array(); - for ( var l = 0; l < theListEls.length; l++ ) { - if ( theListEls[l].id ) - theUserLists[theListEls[l].id] = new listMan(theListEls[l].id); - } - addUserInputs = document.getElementById('adduser').getElementsByTagName('input'); - for ( var i = 0; i < addUserInputs.length; i++ ) { - addUserInputs[i].onkeypress = function(e) { return killSubmit('addUserSubmit();', e); } - } - document.getElementById('addusersub').onclick = function(e) { return killSubmit('addUserSubmit();', e); } -} -); - -function addUserSubmit() { - var roleEl = document.getElementById('role'); - var role = roleEl.options[roleEl.selectedIndex].value; - if ( !theUserLists['role-' + role] ) return true; - return theUserLists['role-' + role].ajaxAdder('user', 'adduser'); -} +jQuery( function($) { $('#users').wpList(); } ); diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js index 6bf7f2c..2802f9b 100644 --- a/wp-admin/js/widgets.js +++ b/wp-admin/js/widgets.js @@ -11,7 +11,7 @@ jQuery(function($) { var widgetAnim = $.browser.msie ? function() { var t = $(this); if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); } + if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } li.css( 'marginLeft', 0 ); t.siblings('h4').children('a').text( widgetsL10n.edit ); } else { @@ -25,7 +25,7 @@ jQuery(function($) { var t = $(this); if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); } + if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } if ( width > 250 ) li.animate( { marginLeft: 0 } ); t.siblings('h4').children('a').text( widgetsL10n.edit ); diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php index 2b06d8e..20e60fd 100644 --- a/wp-admin/link-add.php +++ b/wp-admin/link-add.php @@ -3,7 +3,7 @@ require_once('admin.php'); $title = __('Add Link'); $this_file = 'link-manager.php'; -$parent_file = 'link-manager.php'; +$parent_file = 'post-new.php'; wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', @@ -11,9 +11,10 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]')); -wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') ); -if ( current_user_can( 'manage_categories' ) ) - wp_enqueue_script( 'ajaxlinkcat' ); +wp_enqueue_script('link'); +wp_enqueue_script('xfn'); +wp_enqueue_script('thickbox'); + require('admin-header.php'); ?> @@ -22,16 +23,8 @@ require('admin-header.php'); <?php endif; ?> <?php - $link = get_default_link_to_edit(); - include('edit-link-form.php'); -?> +$link = get_default_link_to_edit(); +include('edit-link-form.php'); -<div id="wp-link-bookmarklet" class="wrap"> -<h3><?php _e('Add Link Bookmarklet'); ?></h3> -<p><?php _e('Right click on the following link and choose “Bookmark This Link...” or “Add to Favorites...” to create a Link This shortcut.'); ?></p> -<?php printf('<p><a href="%s" title="'.__('Link add bookmarklet').'">'.__('Link This').'</a></p>', "javascript:void(linkmanpopup=window.open('" . get_option('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?> -</div> - -<?php require('admin-footer.php'); ?> diff --git a/wp-admin/link-category.php b/wp-admin/link-category.php index 4205892..a67cf2b 100644 --- a/wp-admin/link-category.php +++ b/wp-admin/link-category.php @@ -35,14 +35,22 @@ case 'delete': wp_delete_term($cat_ID, 'link_category'); - wp_redirect('edit-link-categories.php?message=2'); + $location = 'edit-link-categories.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'edit-link-categories.php') ) + $location = $referer; + } + + $location = add_query_arg('message', 2, $location); + + wp_redirect($location); exit; break; case 'edit': $title = __('Categories'); - $parent_file = 'link-manager.php'; + $parent_file = 'edit.php'; $submenu_file = 'edit-link-categories.php'; require_once ('admin-header.php'); $cat_ID = (int) $_GET['cat_ID']; @@ -59,11 +67,18 @@ case 'editedcat': if ( !current_user_can('manage_categories') ) wp_die(__('Cheatin’ uh?')); + $location = 'edit-link-categories.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'edit-link-categories.php') ) + $location = $referer; + } + if ( wp_update_term($cat_ID, 'link_category', $_POST) ) - wp_redirect('edit-link-categories.php?message=3'); + $location = add_query_arg('message', 3, $location); else - wp_redirect('edit-link-categories.php?message=5'); + $location = add_query_arg('message', 5, $location); + wp_redirect($location); exit; break; } diff --git a/wp-admin/link-import.php b/wp-admin/link-import.php index 8dd2866..741a4dd 100644 --- a/wp-admin/link-import.php +++ b/wp-admin/link-import.php @@ -3,9 +3,8 @@ // Copyright (C) 2002 Mike Little -- mike@zed1.com require_once('admin.php'); -$parent_file = 'link-manager.php'; +$parent_file = 'edit.php'; $title = __('Import Blogroll'); -$this_file = 'link-import.php'; $step = $_POST['step']; if (!$step) $step = 0; @@ -30,12 +29,12 @@ switch ($step) { <div style="width: 70%; margin: auto; height: 8em;"> <input type="hidden" name="step" value="1" /> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> -<div style="width: 48%; float: left;"> +<div style="width: 48%;" class="alignleft"> <h3><?php _e('Specify an OPML URL:'); ?></h3> <input type="text" name="opml_url" size="50" style="width: 90%;" value="http://" /> </div> -<div style="width: 48%; float: left;"> +<div style="width: 48%;" class="alignleft"> <h3><?php _e('Or choose from your local disk:'); ?></h3> <input id="userfile" name="userfile" type="file" size="30" /> </div> @@ -54,7 +53,7 @@ foreach ($categories as $category) { ?> </select></p> -<p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File »') ?>" /></p> +<p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File') ?>" /></p> </form> </div> @@ -123,7 +122,7 @@ else } // end else if ( ! $blogrolling ) - apply_filters( 'wp_delete_file', $opml_url); + do_action( 'wp_delete_file', $opml_url); @unlink($opml_url); ?> </div> diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index ade3143..42ec201 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -1,12 +1,30 @@ <?php +require_once ('admin.php'); -// Links -// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com +// Handle bulk deletes +if ( isset($_GET['deleteit']) && isset($_GET['linkcheck']) ) { + check_admin_referer('bulk-bookmarks'); -require_once ('admin.php'); + if ( ! current_user_can('manage_links') ) + wp_die( __('You do not have sufficient permissions to edit the links for this blog.') ); -wp_enqueue_script( 'listman' ); + foreach ( (array) $_GET['linkcheck'] as $link_id) { + $link_id = (int) $link_id; + + wp_delete_link($link_id); + } + + $sendback = wp_get_referer(); + $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); + wp_redirect($sendback); + exit; +} elseif ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; +} + +wp_enqueue_script('admin-forms'); wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]')); @@ -16,8 +34,8 @@ if (empty ($cat_id)) if (empty ($order_by)) $order_by = 'order_name'; -$title = __('Manage Blogroll'); -$this_file = $parent_file = 'link-manager.php'; +$title = __('Manage Links'); +$this_file = $parent_file = 'edit.php'; include_once ("./admin-header.php"); if (!current_user_can('manage_links')) @@ -44,64 +62,67 @@ switch ($order_by) { $sqlorderby = 'name'; break; } -?> -<script type="text/javascript"> -<!-- -function checkAll(form) -{ - for (i = 0, n = form.elements.length; i < n; i++) { - if(form.elements[i].type == "checkbox") { - if(form.elements[i].checked == true) - form.elements[i].checked = false; - else - form.elements[i].checked = true; - } - } -} -//--> -</script> -<?php if ( isset($_GET['deleted']) ) { echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; $deleted = (int) $_GET['deleted']; printf(__ngettext('%s link deleted.', '%s links deleted', $deleted), $deleted); echo '</p></div>'; + $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']); } ?> <div class="wrap"> -<h2><?php _e('Blogroll Management'); ?></h2> -<p><?php _e('Here you <a href="link-add.php">add links</a> to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it’s called a “blogroll.”'); ?></p> -<form id="cats" method="get" action=""> -<p><?php +<form id="posts-filter" action="" method="get"> +<h2><?php printf( __( 'Manage Links (<a href="%s">add new</a>)' ), 'link-add.php' ); ?></h2> + +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" /> + <input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" /> +</p> + +<br class="clear" /> + +<div class="tablenav"> + +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php $categories = get_terms('link_category', "hide_empty=1"); $select_cat = "<select name=\"cat_id\">\n"; -$select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n"; +$select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n"; foreach ((array) $categories as $cat) $select_cat .= '<option value="' . $cat->term_id . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n"; $select_cat .= "</select>\n"; $select_order = "<select name=\"order_by\">\n"; -$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Link ID') . "</option>\n"; -$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Name') . "</option>\n"; -$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Address') . "</option>\n"; -$select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Rating') . "</option>\n"; +$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n"; +$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n"; +$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n"; +$select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n"; $select_order .= "</select>\n"; -printf(__('Currently showing %1$s links ordered by %2$s'), $select_cat, $select_order); +echo $select_cat; +echo $select_order; + ?> -<input type="submit" name="action" value="<?php _e('Update »') ?>" /></p> -</form> +<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" /> + +</div> + +<br class="clear" /> +</div> + +<br class="clear" /> + <?php $link_columns = array( - 'name' => '<th width="15%">' . __('Name') . '</th>', + 'name' => '<th style="width: 15%;">' . __('Name') . '</th>', 'url' => '<th>' . __('URL') . '</th>', 'categories' => '<th>' . __('Categories') . '</th>', 'rel' => '<th style="text-align: center">' . __('rel') . '</th>', 'visible' => '<th style="text-align: center">' . __('Visible') . '</th>', - 'action' => '<th colspan="2" style="text-align: center">' . __('Action') . '</th>', ); $link_columns = apply_filters('manage_link_columns', $link_columns); ?> @@ -109,26 +130,24 @@ $link_columns = apply_filters('manage_link_columns', $link_columns); <?php if ( 'all' == $cat_id ) $cat_id = ''; -$links = get_bookmarks( "category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0" ); +$args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0); +if ( !empty($_GET['s']) ) + $args['search'] = $_GET['s']; +$links = get_bookmarks( $args ); if ( $links ) { ?> -<form id="links" method="post" action="link.php"> <?php wp_nonce_field('bulk-bookmarks') ?> -<input type="hidden" name="link_id" value="" /> -<input type="hidden" name="action" value="" /> -<input type="hidden" name="order_by" value="<?php echo attribute_escape($order_by); ?>" /> -<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> <table class="widefat"> <thead> <tr> + <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> <?php foreach($link_columns as $column_display_name) { echo $column_display_name; } ?> - <th style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th> </tr> </thead> - <tbody id="the-list"> + <tbody> <?php foreach ($links as $link) { $link = sanitize_bookmark($link); @@ -145,10 +164,12 @@ if ( $links ) { ++ $i; $style = ($i % 2) ? '' : ' class="alternate"'; ?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php + echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>'; foreach($link_columns as $column_name=>$column_display_name) { switch($column_name) { case 'name': - ?><td><strong><?php echo $link->link_name; ?></strong><br /><?php + + echo "<td><strong><a class='row-title' href='link.php?link_id=$link->link_id&action=edit' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "' class='edit'>$link->link_name</a></strong><br />"; echo $link->link_description . "</td>"; break; case 'url': @@ -173,11 +194,7 @@ if ( $links ) { ?><td><?php echo $link->link_rel; ?></td><?php break; case 'visible': - ?><td align='center'><?php echo $visible; ?></td><?php - break; - case 'action': - echo '<td><a href="link.php?link_id='.$link->link_id.'&action=edit" class="edit">'.__('Edit').'</a></td>'; - echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." onclick=\"return deleteSomething( 'link', $link->link_id , '".js_escape(sprintf(__("You are about to delete the '%s' link to %s.\n'Cancel' to stop, 'OK' to delete."), $link->link_name, $link->link_url )).'\' );" class="delete">'.__('Delete').'</a></td>'; + ?><td style='text-align: center;'><?php echo $visible; ?></td><?php break; default: ?> @@ -187,19 +204,23 @@ if ( $links ) { } } - echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>'; echo "\n </tr>\n"; } ?> </tbody> </table> +<?php } else { ?> +<p><?php _e('No links found.') ?></p> +<?php } ?> +</form> + <div id="ajax-response"></div> -<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links »') ?>" onclick="return confirm('<?php echo js_escape(__("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete.")); ?>')" /></p> -</form> +<div class="tablenav"> +<br class="clear" /> +</div> -<?php } ?> </div> diff --git a/wp-admin/link.php b/wp-admin/link.php index 383f6e4..8766a71 100644 --- a/wp-admin/link.php +++ b/wp-admin/link.php @@ -83,10 +83,11 @@ switch ($action) { break; case 'edit' : - wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') ); - if ( current_user_can( 'manage_categories' ) ) - wp_enqueue_script( 'ajaxlinkcat' ); - $parent_file = 'link-manager.php'; + wp_enqueue_script('link'); + wp_enqueue_script('xfn'); + wp_enqueue_script('thickbox'); + + $parent_file = 'edit.php'; $submenu_file = 'link-manager.php'; $title = __('Edit Link'); diff --git a/wp-admin/media.php b/wp-admin/media.php index bd64104..b280d3a 100644 --- a/wp-admin/media.php +++ b/wp-admin/media.php @@ -8,15 +8,25 @@ $submenu_file = 'upload.php'; wp_reset_vars(array('action')); switch( $action ) : -case 'upload' : -case 'delete' : break; // stubs case 'editattachment' : $errors = media_upload_form_handler(); + $attachment_id = (int) $_POST['attachment_id']; if ( empty($errors) ) { - wp_redirect( add_query_arg( 'message', 'updated' ) ); + $location = 'media.php'; + if ( $referer = wp_get_original_referer() ) { + if ( false !== strpos($referer, 'upload.php') || ( url_to_postid($referer) == $attachment_id ) ) + $location = $referer; + } + if ( false !== strpos($location, 'upload.php') ) { + $location = remove_query_arg('message', $location); + $location = add_query_arg('posted', $attachment_id, $location); + } elseif ( false !== strpos($location, 'media.php') ) { + $location = add_query_arg('message', 'updated', $location); + } + wp_redirect($location); exit; - break; } + // no break case 'edit' : $title = __('Edit Media'); @@ -67,7 +77,9 @@ case 'edit' : <p class="submit"> <input type="submit" class="button" name="save" value="<?php _e('Save Changes'); ?>" /> <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> +<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $att_id; ?>" /> <input type="hidden" name="action" value="editattachment" /> +<?php wp_original_referer_field(true, 'previous'); ?> <?php wp_nonce_field('media-form'); ?> </p> @@ -78,10 +90,13 @@ case 'edit' : require( 'admin-footer.php' ); - break; + exit; + +default: + wp_redirect( 'upload.php' ); + exit; + endswitch; -wp_redirect( 'upload.php' ); -exit; ?> diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php index f6a3b7d..4c0ca13 100644 --- a/wp-admin/menu-header.php +++ b/wp-admin/menu-header.php @@ -1,4 +1,3 @@ -<ul id="adminmenu"> <?php $self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']); $self = preg_replace('|^.*/plugins/|i', '', $self); @@ -6,7 +5,68 @@ $self = preg_replace('|^.*/mu-plugins/|i', '', $self); get_admin_page_parent(); -foreach ($menu as $item) { +// We're going to do this loop three times +?> + +<ul id="dashmenu"> +<?php +foreach ( $menu as $key => $item ) { + if ( 3 < $key ) // get each menu item before 3 + continue; + $class = ''; + // 0 = name, 1 = capability, 2 = file + if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; + + if ( !empty($submenu[$item[2]]) ) { + $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. + $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) + echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; + else + echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; + } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$item[2]}") || !empty($menu_hook)) + echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; + else + echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; + } +} +do_action( 'dashmenu' ); +?> +</ul> + +<ul id="adminmenu"> +<?php +foreach ( $menu as $key => $item ) { + if ( 5 > $key || $key > 25 ) // get each menu item before 3 + continue; + + $class = ''; + + // 0 = name, 1 = capability, 2 = file + if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; + + if ( !empty($submenu[$item[2]]) ) { + $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. + $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) + echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; + else + echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; + } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$item[2]}") || !empty($menu_hook)) + echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; + else + echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; + } +} + +foreach ( $menu as $key => $item ) { + if ( $key < 41 ) // there is a more efficient way to do this! + continue; + $class = ''; // 0 = name, 1 = capability, 2 = file @@ -20,6 +80,7 @@ foreach ($menu as $item) { else echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$item[2]}") ) echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; else @@ -27,9 +88,44 @@ foreach ($menu as $item) { } } +do_action( 'adminmenu' ); +?> +</ul> + +<ul id="sidemenu"> +<?php +$side_items = array(); +foreach ( $menu as $key => $item ) { + if ( 26 > $key || $key > 40 ) + continue; + + $class = ''; + + // 0 = name, 1 = capability, 2 = file + if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; + + if ( !empty($submenu[$item[2]]) ) { + $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. + $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$item[2]}") ) + $side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; + else + $side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; + } else if ( current_user_can($item[1]) ) { + $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); + if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || file_exists(ABSPATH . MUPLUGINDIR . "/{$item[2]}") ) + $side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>"; + else + $side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>"; + } +} +echo implode(' </li>', $side_items) . '</li>'; +unset($side_items); +do_action( 'sidemenu' ); ?> </ul> + <?php // Sub-menu if ( isset($submenu["$parent_file"]) ) : diff --git a/wp-admin/menu.php b/wp-admin/menu.php index a151ce1..342f1ee 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -8,45 +8,44 @@ $menu[0] = array(__('Dashboard'), 'read', 'index.php'); if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false) $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); +elseif (strpos($_SERVER['REQUEST_URI'], 'link-manager.php') !== false) + $menu[5] = array(__('Write'), 'manage_links', 'link-add.php'); else $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); + if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false) $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); +elseif (strpos($_SERVER['REQUEST_URI'], 'link-add.php') !== false) + $menu[10] = array(__('Manage'), 'manage_links', 'link-manager.php'); else $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); -$menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); -$menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php'); -$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); -$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); +$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); +$menu[15] = array(__('Design'), 'switch_themes', 'themes.php'); +$menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>$awaiting_mod</span></span>" ), 'edit_posts', 'edit-comments.php'); +$menu[30] = array(__('Settings'), 'manage_options', 'options-general.php'); +$menu[35] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); if ( current_user_can('edit_users') ) - $menu[35] = array(__('Users'), 'edit_users', 'users.php'); + $menu[40] = array(__('Users'), 'edit_users', 'users.php'); else - $menu[35] = array(__('Profile'), 'read', 'profile.php'); -$menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); - + $menu[40] = array(__('Profile'), 'read', 'profile.php'); $_wp_real_parent_file['post.php'] = 'post-new.php'; // Back-compat -$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php'); -$submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php'); +$submenu['post-new.php'][5] = array(__('Post'), 'edit_posts', 'post-new.php'); +$submenu['post-new.php'][10] = array(__('Page'), 'edit_pages', 'page-new.php'); +$submenu['post-new.php'][15] = array(__('Link'), 'manage_links', 'link-add.php'); $submenu['edit-comments.php'][5] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); -$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); -$submenu['edit-comments.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php'); - $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); -$submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php'); -$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php'); -$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php'); -$submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php'); -$submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php'); - -$submenu['link-manager.php'][5] = array(__('Manage Blogroll'), 'manage_links', 'link-manager.php'); -$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php'); -$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); -$submenu['link-manager.php'][30] = array(__('Categories'), 'manage_links', 'edit-link-categories.php'); +$submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php'); +$submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php'); +$submenu['edit.php'][25] = array(__('Tags'), 'manage_categories', 'edit-tags.php'); +$submenu['edit.php'][30] = array(__('Link Categories'), 'manage_categories', 'edit-link-categories.php'); +$submenu['edit.php'][35] = array(__('Media Library'), 'upload_files', 'upload.php'); +$submenu['edit.php'][40] = array(__('Import'), 'import', 'import.php'); +$submenu['edit.php'][45] = array(__('Export'), 'import', 'export.php'); if ( current_user_can('edit_users') ) { $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. @@ -137,7 +136,7 @@ unset($id); uksort($menu, "strnatcasecmp"); // make it all pretty if (! user_can_access_admin_page()) { - do_action( 'admin_menu_permission' ); + do_action('admin_page_access_denied'); wp_die( __('You do not have sufficient permissions to access this page.') ); } diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php index 2048a6e..6750ac3 100644 --- a/wp-admin/moderation.php +++ b/wp-admin/moderation.php @@ -1,226 +1,4 @@ <?php - -require_once './admin.php'; - -$title = __( 'Moderate Comments' ); -$parent_file = 'edit-comments.php'; - -wp_enqueue_script( 'admin-comments' ); - -wp_reset_vars( array( 'action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky' ) ); - -$comment = array(); - -if ( isset( $_POST['comment'] ) && is_array( $_POST['comment'] ) ) { - foreach ( $_POST['comment'] as $k => $v ) { - $comment[intval( $k )] = $v; - } -} - -if ( $action == 'update' ) { - check_admin_referer( 'moderate-comments' ); - - if ( !current_user_can( 'moderate_comments' ) ) { - wp_die( __( 'Your level is not high enough to moderate comments.' ) ); - } - - $item_ignored = 0; - $item_deleted = 0; - $item_approved = 0; - $item_spam = 0; - - foreach ( $comment as $k => $v ) { - if ( $feelinglucky && $v == 'later' ) { - $v = 'delete'; - } - - switch ( $v ) { - case 'later' : - $item_ignored++; - break; - - case 'delete' : - wp_set_comment_status( $k, 'delete' ); - $item_deleted++; - break; - - case 'spam' : - wp_set_comment_status( $k, 'spam' ); - $item_spam++; - break; - - case 'approve' : - wp_set_comment_status( $k, 'approve' ); - - if ( get_option( 'comments_notify' ) == true ) { - wp_notify_postauthor( $k ); - } - - $item_approved++; - break; - } - } - - wp_redirect( basename( __FILE__ ) . '?ignored=' . $item_ignored . '&deleted=' . $item_deleted . '&approved=' . $item_approved . '&spam=' . $item_spam ); - exit; -} - -require_once './admin-header.php'; - -if ( !current_user_can( 'moderate_comments' ) ) { - echo '<div class="wrap"><p>' . __( 'Your level is not high enough to moderate comments.' ) . '</p></div>'; - include_once './admin-footer.php'; - exit; -} - -if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) { - $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; - $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; - $spam = isset( $_GET['ignored'] ) ? (int) $_GET['spam'] : 0; - - if ( $approved > 0 || $deleted > 0 || $spam > 0 ) { - echo '<div id="moderated" class="updated fade"><p>'; - - if ( $approved > 0 ) { - printf( __ngettext( '%s comment approved.', '%s comments approved.', $approved ), $approved ); - echo '<br />'; - } - - if ( $deleted > 0 ) { - printf( __ngettext( '%s comment deleted', '%s comments deleted.', $deleted ), $deleted ); - echo '<br />'; - } - - if ( $spam > 0 ) { - printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); - echo '<br />'; - } - - echo '</p></div>'; - } -} - +require_once('../wp-config.php'); +wp_redirect('edit-comments.php?comment_status=moderated'); ?> -<div class="wrap"> -<?php - -$comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'" ); - -if ( !$comments ) { - echo '<p>' . __( 'Currently there are no comments for you to moderate.' ) . '</p></div>'; - include_once './admin-footer.php'; - exit; -} - -$total = count( $comments ); -$per = 100; - -if ( isset( $_GET['paged'] ) ) { - $page = (int) $_GET['paged']; -} else { - $page = 1; -} - -$start = ( $page * $per ) - $per; -$stop = $start + $per; - -$page_links = paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'total' => ceil( $total / $per ), - 'current' => $page, - 'prev_text' => '«', - 'next_text' => '»' -) ); - -$comments = array_slice( $comments, $start, $stop ); - -?> - <h2><?php _e( 'Moderation Queue' ); ?></h2> - - <?php - if ( $page_links ) { - echo '<p class="pagenav">' . $page_links . '</p>'; - } - ?> - - <form name="approval" id="approval" action="<?php echo basename( __FILE__ ); ?>" method="post"> - <?php wp_nonce_field( 'moderate-comments' ); ?> - <input type="hidden" name="action" value="update" /> - <ol id="the-comments-list" class="commentlist"> - <?php - $i = 0; - - foreach ( $comments as $comment ) { - $class = 'js-unapproved'; - - if ( $i++ % 2 ) { - $class .= ' alternate'; - } - ?> - <li id="comment-<?php comment_ID(); ?>" class="<?php echo $class; ?>"> - <p> - <strong><?php comment_author(); ?></strong> - <?php if ( !empty( $comment->comment_author_email ) ) { ?>| <?php comment_author_email_link(); ?> <?php } ?> - <?php if ( !empty( $comment->comment_author_url ) && $comment->comment_author_url != 'http://' ) { ?>| <?php comment_author_url_link(); ?> <?php } ?> - | <?php _e( 'IP:' ); ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP(); ?>"><?php comment_author_IP(); ?></a> - </p> - - <p> - <?php comment_text(); ?> - </p> - - <p><small> - <?php comment_date( __( 'M j, g:i A' ) ); ?> — - [ <a href="comment.php?action=editcomment&c=<?php comment_ID(); ?>" title="<?php _e( 'Edit this comment' ); ?>"><?php _e( 'Edit' ); ?></a> | - <a href="post.php?action=deletecomment&p=<?php echo $comment->comment_post_ID; ?>" title="<?php _e( 'Delete this comment' ); ?>" onclick="return deleteSomething( 'comment', <?php comment_ID(); ?>, '<?php echo js_escape( sprintf( __( "You are about to delete this comment by '%s'.\n'OK' to delete, 'Cancel' to stop." ), get_comment_author() ) ); ?>', theCommentList );"><?php _e( 'Delete' ); ?></a> ] — - <a href="<?php echo get_permalink( $comment->comment_post_ID ); ?>" title="<?php _e( 'View the post' ); ?>"><?php printf( __( 'View post “%s”' ), get_the_title( $comment->comment_post_ID ) ); ?></a> - </small></p> - - <p><small> - <?php _e( 'Bulk action:' ); ?> - <label for="comment-<?php comment_ID(); ?>-approve"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-approve" value="approve" /> <?php _e( 'Approve' ); ?></label> - <label for="comment-<?php comment_ID(); ?>-spam"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-spam" value="spam" /> <?php _e( 'Spam' ); ?></label> - <label for="comment-<?php comment_ID(); ?>-delete"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-delete" value="delete" /> <?php _e( 'Delete' ); ?></label> - <label for="comment-<?php comment_ID(); ?>-nothing"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-nothing" value="later" checked="checked" /> <?php _e( 'No action' ); ?></label> - </small></p> - </li> - <?php - } - ?> - </ol> - - <?php - if ( $page_links ) { - echo '<p class="pagenav">' . $page_links . '</p>'; - } - ?> - - <div id="ajax-response"></div> - - <noscript> - <p class="submit"> - <label for="feelinglucky"><input name="feelinglucky" id="feelinglucky" type="checkbox" value="true" /> <?php _e( 'Delete every comment marked “defer.” <strong>Warning: This can’t be undone.</strong>' ); ?></label> - </p> - </noscript> - - <p class="submit"> - <input type="submit" id="submit" name="submit" value="<?php _e( 'Bulk Moderate Comments »' ); ?>" /> - </p> - - <script type="text/javascript"> - // <![CDATA[ - function mark_all_as( what ) { - for ( var i = 0; i < document.approval.length; i++ ) { - if ( document.approval[i].value == what ) { - document.approval[i].checked = true; - } - } - } - - document.write( '<p><strong><?php _e( 'Mark all:' ); ?></strong> <a href="javascript:mark_all_as(\'approve\')"><?php _e( 'Approved' ); ?></a> – <a href="javascript:mark_all_as(\'spam\')"><?php _e( 'Spam' ); ?></a> – <a href="javascript:mark_all_as(\'delete\')"><?php _e( 'Deleted' ); ?></a> – <a href="javascript:mark_all_as(\'later\')"><?php _e( 'Later' ); ?></a></p>' ); - // ]]> - </script> - </form> -</div> -<?php include_once './admin-footer.php'; ?> diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index 3f8ce72..09f380e 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -1,84 +1,122 @@ <?php require_once('admin.php'); -$title = __('Discussion Options'); +$title = __('Discussion Settings'); $parent_file = 'options-general.php'; include('admin-header.php'); ?> <div class="wrap"> -<h2><?php _e('Discussion Options') ?></h2> +<h2><?php _e('Discussion Settings') ?></h2> <form method="post" action="options.php"> -<?php wp_nonce_field('discussion-options') ?> <input type='hidden' name='option_page' value='discussion' /> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /></p> -<fieldset class="options"> -<legend><?php echo __('Usual settings for an article:').'<br /><small><em>('.__('These settings may be overridden for individual articles.').')</em></small>'; ?></legend> -<ul> -<li> +<?php wp_nonce_field('discussion-options') ?> +<table class="form-table"> +<tr valign="top"> +<th scope="row"><?php _e('Default article settings') ?></th> +<td> <label for="default_pingback_flag"> <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> /> <?php _e('Attempt to notify any blogs linked to from the article (slows down posting.)') ?></label> -</li> -<li> +<br /> <label for="default_ping_status"> <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> /> <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks.)') ?></label> -</li> -<li> +<br /> <label for="default_comment_status"> <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> /> <?php _e('Allow people to post comments on the article') ?></label> -</li> -</ul> -</fieldset> -<fieldset class="options"> -<legend><?php _e('E-mail me whenever:') ?></legend> -<ul> -<li> +<br /> +<small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small> +</td> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('E-mail me whenever') ?></th> +<td> <label for="comments_notify"> <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> /> <?php _e('Anyone posts a comment') ?> </label> -</li> -<li> +<br /> <label for="moderation_notify"> <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> /> <?php _e('A comment is held for moderation') ?> </label> -</li> -</ul> -</fieldset> -<fieldset class="options"> -<legend><?php _e('Before a comment appears:') ?></legend> -<ul> -<li> +</td> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('Before a comment appears') ?></th> +<td> <label for="comment_moderation"> <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> /> <?php _e('An administrator must always approve the comment') ?> </label> -</li> -<li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li> -<li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li> -</ul> -</fieldset> -<fieldset class="options"> -<legend><?php _e('Comment Moderation') ?></legend> +<br /> +<label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label> +<br /> +<label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label> +</td> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('Comment Moderation') ?></th> +<td> <p><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_option('comment_max_links'). '" />' ) ?></p> -<p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="moderation.php">moderation queue</a>. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p> +<p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p> <p> -<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea> +<textarea name="moderation_keys" cols="60" rows="10" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea> </p> -</fieldset> -<fieldset class="options"> -<legend><?php _e('Comment Blacklist') ?></legend> +</td> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('Comment Blacklist') ?></th> +<td> <p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p> <p> -<textarea name="blacklist_keys" cols="60" rows="4" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea> +<textarea name="blacklist_keys" cols="60" rows="10" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea> </p> -</fieldset> +</td> +</tr> +</table> + +<h3><?php _e('Avatars') ?></h3> + +<p><?php _e('By default WordPress uses <a href="http://gravatar.com/">Gravatars</a> — short for Globally Recognized Avatars — for the pictures that show up next to comments. Plugins may override this.'); ?></p> + +<?php // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? ?> + +<table class="form-table"> +<tr valign="top"> +<th scope="row"><?php _e('Avatar display') ?></th> +<td> +<?php + $yesorno = array(0 => __("Don’t show Avatars"), 1 => __('Show Avatars')); + foreach ( $yesorno as $key => $value) { + $selected = (get_option('show_avatars') == $key) ? 'checked="checked"' : ''; + echo "\n\t<label><input type='radio' name='show_avatars' value='$key' $selected> $value</label><br />"; + } +?> +</td> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('Maximum Rating') ?></th> +<td> + +<?php +$ratings = array( 'G' => __('G — Suitable for all audiences'), 'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'), 'R' => __('R — Intended for adult audiences above 17'), 'X' => __('X — Even more mature than above')); +foreach ($ratings as $key => $rating) : + $selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : ''; + echo "\n\t<label><input type='radio' name='avatar_rating' value='$key' $selected> $rating</label><br />"; +endforeach; +?> + +</td> +</tr> + +</table> + + <p class="submit"> <input type="hidden" name="action" value="update" /> -<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> +<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index d05e8db..e2be9c0 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -1,45 +1,96 @@ <?php require_once('./admin.php'); -$title = __('General Options'); +$title = __('General Settings'); $parent_file = 'options-general.php'; include('./admin-header.php'); ?> <div class="wrap"> -<h2><?php _e('General Options') ?></h2> +<h2><?php _e('General Settings') ?></h2> <form method="post" action="options.php"> <?php wp_nonce_field('general-options') ?> <input type='hidden' name='option_page' value='general' /> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /></p> -<table class="optiontable"> +<table class="form-table"> <tr valign="top"> -<th scope="row"><?php _e('Blog title:') ?></th> +<th scope="row"><?php _e('Blog Title') ?></th> <td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td> </tr> <tr valign="top"> -<th scope="row"><?php _e('Tagline:') ?></th> +<th scope="row"><?php _e('Tagline') ?></th> <td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php form_option('blogdescription'); ?>" size="45" /> <br /> <?php _e('In a few words, explain what this blog is about.') ?></td> -</tr> -<tr valign="top"> -<th scope="row"><?php _e('Membership:') ?></th> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('E-mail address') ?> </th> +<td><input name="new_admin_email" type="text" id="new_admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" /> +<br /> +<?php _e('This address is used only for admin purposes.') ?> <?php _e('If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>') ?></td> +</tr> +<tr valign="top"> +<th scope="row"><?php _e('Membership') ?></th> <td> <label for="comment_registration"> <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> /> <?php _e('Users must be registered and logged in to comment') ?> </label> -</td> -</tr> -<tr valign="top"> -<th scope="row"><?php _e('E-mail address:') ?> </th> -<td><input name="new_admin_email" type="text" id="new_admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" /> -<br /> -<p><?php _e('This address is used only for admin purposes.') ?> <?php _e('If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>') ?></p> -</td> +</td> </tr> +<tr> +<th scope="row"><?php _e('Timezone') ?> </th> +<td> +<select name="gmt_offset"> +<?php +$current_offset = get_option('gmt_offset'); +$offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, + 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14); +foreach ( $offset_range as $offset ) { + if ( 0 < $offset ) + $offset_name = '+' . $offset; + elseif ( 0 == $offset ) + $offset_name = ''; + else + $offset_name = (string) $offset; + $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name); + + $selected = ''; + if ( $current_offset == $offset ) { + $selected = " selected='selected'"; + $current_offset_name = $offset_name; + } + echo "<option value=\"$offset\"$selected>" . sprintf(__('UTC %s'), $offset_name) . '</option>'; +} +?> +</select> +<?php _e('hours') ?><br /> +<?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), gmdate(__('Y-m-d G:i:s'))); ?><br /> +<?php if ($current_offset) printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, gmdate(__('Y-m-d G:i:s'), current_time('timestamp'))); ?> +</td> +</tr> +<tr> +<th scope="row"><?php _e('Date Format') ?></th> +<td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br /> +<?php _e('Output:') ?> <strong><?php echo mysql2date(get_option('date_format'), current_time('mysql')); ?></strong></td> +</tr> +<tr> +<th scope="row"><?php _e('Time Format') ?></th> +<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br /> +<?php _e('Output:') ?> <strong><?php echo gmdate(get_option('time_format'), current_time('timestamp')); ?></strong><br /> +<?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') ?></td> +</tr> +<tr> +<th scope="row"><?php _e('Week Starts On') ?></th> +<td><select name="start_of_week" id="start_of_week"> +<?php +for ($day_index = 0; $day_index <= 6; $day_index++) : + $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : ''; + echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>'; +endfor; +?> +</select></td> +</tr> <?php $lang_files = glob( ABSPATH . LANGDIR . '/*.mo' ); $lang = get_option('WPLANG'); @@ -63,48 +114,9 @@ if( is_array( $lang_files ) ) { <?php } // languages ?> -</table> -<fieldset class="options"> -<legend><?php _e('Date and Time') ?></legend> -<table class="optiontable"> -<tr> -<th scope="row"><?php _e('<abbr title="Coordinated Universal Time">UTC</abbr> time is:') ?> </th> -<td><code><?php echo gmdate(__('Y-m-d g:i:s a')); ?></code></td> -</tr> -<tr> -<th scope="row"><?php _e('Times in the blog should differ by:') ?> </th> -<td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" /> -<?php _e('hours') ?> (<?php _e('Your timezone offset, for example <code>-6</code> for Central Time.'); ?>)</td> -</tr> -<tr> -<th scope="row"><?php _e('Default date format:') ?></th> -<td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br /> -<?php _e('Output:') ?> <strong><?php echo mysql2date(get_option('date_format'), current_time('mysql')); ?></strong></td> -</tr> -<tr> -<th scope="row"><?php _e('Default time format:') ?></th> -<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br /> -<?php _e('Output:') ?> <strong><?php echo gmdate(get_option('time_format'), current_time('timestamp')); ?></strong></td> -</tr> -<tr> -<th scope="row"> </th> -<td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Update options" to update sample output.') ?> </td> -</tr> -<tr> -<th scope="row"><?php _e('Weeks in the calendar should start on:') ?></th> -<td><select name="start_of_week" id="start_of_week"> -<?php -for ($day_index = 0; $day_index <= 6; $day_index++) : - $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : ''; - echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>'; -endfor; -?> -</select></td> -</tr> </table> -</fieldset> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> +<p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> <input type="hidden" name="action" value="update" /> </p> </form> diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php index da1784f..3838018 100644 --- a/wp-admin/options-head.php +++ b/wp-admin/options-head.php @@ -1,5 +1,5 @@ <?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?> <?php if (isset($_GET['updated'])) : ?> -<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div> +<div id="message" class="updated fade"><p><strong><?php _e('Settings saved.') ?></strong></p></div> <?php endif; ?> diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index ded2de4..711e61e 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -1,8 +1,7 @@ <?php -die(); require_once('admin.php'); -$title = __('Miscellaneous Options'); +$title = __('Miscellaneous Settings'); $parent_file = 'options-general.php'; include('admin-header.php'); @@ -10,42 +9,40 @@ include('admin-header.php'); ?> <div class="wrap"> -<h2><?php _e('Miscellaneous Options') ?></h2> +<h2><?php _e('Miscellaneous Settings') ?></h2> <form method="post" action="options.php"> -<?php wp_nonce_field('misc-options') ?> <input type='hidden' name='option_page' value='misc' /> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /></p> -<fieldset class="options"> -<legend><?php _e('Uploading'); ?></legend> -<table class="editform optiontable"> +<?php wp_nonce_field('misc-options') ?> + +<h3><?php _e('Image sizes') ?></h3> +<p><?php _e('The sizes listed below determine the maximum dimensions to use when inserting an image into the body of a post.'); ?></p> + +<table class="form-table"> <tr valign="top"> -<th scope="row"><?php _e('Store uploads in this folder'); ?>:</th> -<td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo attribute_escape(str_replace(ABSPATH, '', get_option('upload_path'))); ?>" size="40" /> -<br /> -<?php _e('Default is <code>wp-content/uploads</code>'); ?> +<th scope="row"><?php _e('Thumbnail size') ?></th> +<td> +<label for="thumbnail_size_w"><?php _e('Width'); ?></label> +<input name="thumbnail_size_w" type="text" id="thumbnail_size_w" value="<?php form_option('thumbnail_size_w'); ?>" size="6" /> +<label for="thumbnail_size_h"><?php _e('Height'); ?></label> +<input name="thumbnail_size_h" type="text" id="thumbnail_size_h" value="<?php form_option('thumbnail_size_h'); ?>" size="6" /><br /> +<input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked('1', get_option('thumbnail_crop')); ?>/> +<label for="thumbnail_crop"><?php _e('Crop thumbnail to exact dimensions (normally thumbnails are proportional)'); ?></label> </td> </tr> -<tr> -<td></td> +<tr valign="top"> +<th scope="row"><?php _e('Medium size') ?></th> <td> -<label for="uploads_use_yearmonth_folders"> -<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1" <?php checked('1', get_option('uploads_use_yearmonth_folders')); ?> /> -<?php _e('Organize my uploads into month- and year-based folders'); ?> -</label> +<label for="medium_size_w"><?php _e('Max Width'); ?></label> +<input name="medium_size_w" type="text" id="medium_size_w" value="<?php form_option('medium_size_w'); ?>" size="6" /> +<label for="medium_size_h"><?php _e('Max Height'); ?></label> +<input name="medium_size_h" type="text" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" size="6" /> </td> </tr> </table> -</fieldset> - -<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_option('use_linksupdate')); ?> /> -<label for="use_linksupdate"><?php _e('Track Links’ Update Times') ?></label></p> -<p> -<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_option('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label> -</p> <p class="submit"> <input type="hidden" name="action" value="update" /> -<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> +<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" class="button" /> </p> </form> </div> diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index cce319c..76e3eb2 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -1,7 +1,7 @@ <?php require_once('admin.php'); -$title = __('Permalink Options'); +$title = __('Permalink Settings'); $parent_file = 'options-general.php'; function add_js() { @@ -121,7 +121,6 @@ else <h2><?php _e('Customize Permalink Structure') ?></h2> <form name="form" action="options-permalink.php" method="post"> <?php wp_nonce_field('update-permalink') ?> -<p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /></p> <p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p> <?php @@ -133,53 +132,66 @@ if ( ! got_mod_rewrite() ) $structures = array( '', $prefix . '/%year%/%monthnum%/%day%/%postname%/', + $prefix . '/%year%/%monthnum%/%postname%/', $prefix . '/archives/%post_id%' ); ?> -<h3><?php _e('Common options:'); ?></h3> -<p> - <label> -<input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> /> -<?php _e('Date and name based'); ?><br /> <span> » <code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span> - </label> -</p> -<p> - <label> -<input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> -<?php _e('Numeric'); ?><br /> <span> » <code><?php echo get_option('home') . $prefix ; ?>/archives/123</code></span> - </label> -</p> -<p> -<label> -<input name="selection" id="custom_selection" type="radio" value="custom" class="tog" -<?php if ( !in_array($permalink_structure, $structures) ) { ?> -checked="checked" -<?php } ?> - /> -<?php _e('Custom, specify below'); ?> -</label> -<br /> -</p> -<p id="customstructure"><?php _e('Custom structure'); ?>: <?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $permalink_structure = str_replace( "/blog", "", $permalink_structure ); }?><input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape( $permalink_structure ); ?>" size="50" /></p> +<h3><?php _e('Common settings'); ?></h3> +<table class="form-table"> + <tr> + <th><label><input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> /> <?php _e('Default'); ?></label></th> + <td><code><?php echo get_option('home'); ?>/?p=123</code></td> + </tr> + <tr> + <th><label><input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> /> <?php _e('Day and name'); ?></label></th> + <td><code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></td> + </tr> + <tr> + <th><label><input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> <?php _e('Month and name'); ?></label></th> + <td><code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/sample-post/'; ?></code></td> + </tr> + <tr> + <th><label><input name="selection" type="radio" value="<?php echo $structures[3]; ?>" class="tog" <?php checked($structures[3], $permalink_structure); ?> /> <?php _e('Numeric'); ?></label></th> + <td><code><?php echo get_option('home') . $prefix ; ?>/archives/123</code></td> + </tr> + <tr> + <th> + <label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" + <?php if ( !in_array($permalink_structure, $structures) ) { ?> + checked="checked" + <?php } ?> + /> + <?php _e('Custom Structure'); ?> + </label> + </th> + <td> + <?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $permalink_structure = str_replace( "/blog", "", $permalink_structure ); }?> + <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape($permalink_structure); ?>" size="50" /> + </td> + </tr> +</table> <h3><?php _e('Optional'); ?></h3> <?php if ($is_apache) : ?> - <p><?php _e('If you like, you may enter custom bases for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> + <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> <?php else : ?> - <p><?php _e('If you like, you may enter custom bases for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> + <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> <?php endif; ?> - <p> - <?php _e('Category base'); ?>: <?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $category_base = str_replace( "/blog", "", $category_base ); }?><input name="category_base" type="text" class="code" value="<?php echo attribute_escape( $category_base ); ?>" size="30" /> - </p> - <p> - <?php _e('Tag base'); ?>: <?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $tag_base = str_replace( "/blog", "", $tag_base ); }?> <input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" /> - </p> - <p class="submit"> - <input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /> - </p> + +<table class="form-table"> + <tr> + <th><?php _e('Category base'); ?></th> + <td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $category_base = str_replace( "/blog", "", $category_base ); }?> <input name="category_base" type="text" class="code" value="<?php echo attribute_escape( $category_base ); ?>" size="30" /></td> + </tr> + <tr> + <th><?php _e('Tag base'); ?></th> + <td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $tag_base = str_replace( "/blog", "", $tag_base ); }?> <input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" /></td> + </tr> +</table> +<p class="submit"><input type="submit" name="submit" class="button" value="<?php _e('Save Changes') ?>" /></p> </form> <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?> - <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> + <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> <form action="options-permalink.php" method="post"> <?php wp_nonce_field('update-permalink') ?> <p><textarea rows="5" style="width: 98%;" name="rules" id="rules"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?></textarea></p> diff --git a/wp-admin/options-privacy.php b/wp-admin/options-privacy.php index 62b5135..c3f68dc 100644 --- a/wp-admin/options-privacy.php +++ b/wp-admin/options-privacy.php @@ -1,7 +1,7 @@ <?php require_once('./admin.php'); -$title = __('Privacy Options'); +$title = __('Privacy Settings'); $parent_file = 'options-general.php'; include('./admin-header.php'); @@ -11,25 +11,24 @@ if( trim( get_option('blog_public') ) == '' ) ?> <div class="wrap"> -<h2><?php _e('Privacy Options') ?></h2> +<h2><?php _e('Privacy Settings') ?></h2> <form method="post" action="options.php"> <?php wp_nonce_field('privacy-options') ?> <input type='hidden' name='option_page' value='privacy' /> -<table class="optiontable"> +<table class="form-table"> <tr valign="top"> -<th scope="row"><?php _e('Blog visibility:') ?> </th> +<th scope="row"><?php _e('Blog Visibility') ?> </th> <td> -<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> /> - <label for="blog-public"><?php _e('I would like my blog to be visible to anyone who visits, including search engines, archivers and in public listings around this site.') ?></label> -<br /> -<input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> /> - <label for="blog-norobots"><?php _e( 'I would like to block search engines, but allow normal visitors' ); ?></label> +<p><input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> /> +<label for="blog-public"><?php _e('I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers and in public listings around this site.') ?></label></p> +<p><input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> /> +<label for="blog-norobots"><?php _e('I would like to block search engines, but allow normal visitors'); ?></label></p> <?php do_action('blog_privacy_selector'); ?> </td> </tr> </table> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> +<p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> <input type="hidden" name="action" value="update" /> </p> </form> diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php index 08900bc..147841a 100644 --- a/wp-admin/options-reading.php +++ b/wp-admin/options-reading.php @@ -1,24 +1,21 @@ <?php require_once('admin.php'); -$title = __('Reading Options'); +$title = __('Reading Settings'); $parent_file = 'options-general.php'; include('admin-header.php'); ?> <div class="wrap"> -<h2><?php _e('Reading Options') ?></h2> +<h2><?php _e('Reading Settings') ?></h2> <form name="form1" method="post" action="options.php"> <?php wp_nonce_field('reading-options') ?> <input type='hidden' name='option_page' value='reading' /> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /></p> +<table class="form-table"> <?php if ( get_pages() ): ?> -<fieldset class="options"> -<legend><?php _e('Front Page') ?></legend> -<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> <tr valign="top"> -<th width="33%" scope="row"><?php _e('Front page displays:')?></th> +<th scope="row"><?php _e('Front page displays')?></th> <td> <p><label> <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked('posts', get_option('show_on_front')); ?> /> @@ -43,49 +40,34 @@ include('admin-header.php'); <?php endif; ?> </td> </tr> -</table> -</fieldset> <?php endif; ?> - -<fieldset class="options"> -<legend><?php _e('Blog Pages') ?></legend> -<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> <tr valign="top"> -<th width="33%" scope="row"><?php _e('Show at most:') ?></th> +<th scope="row"><?php _e('Blog pages show at most') ?></th> <td> <input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" /> <?php _e('posts') ?> </td> </tr> -</table> -</fieldset> - -<fieldset class="options"> -<legend><?php _e('Syndication Feeds') ?></legend> -<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> <tr valign="top"> -<th width="33%" scope="row"><?php _e('Show the most recent:') ?></th> +<th scope="row"><?php _e('Syndication feeds show the most recent') ?></th> <td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" size="3" /> <?php _e('posts') ?></td> </tr> <tr valign="top"> -<th scope="row"><?php _e('For each article, show:') ?> </th> +<th scope="row"><?php _e('For each article in a feed, show') ?> </th> <td> <p><label><input name="rss_use_excerpt" type="radio" value="0" <?php checked(0, get_option('rss_use_excerpt')); ?> /> <?php _e('Full text') ?></label><br /> <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_option('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label></p> -<p><?php _e('Note: If you use the <code><!--more--></code> feature, it will cut off posts in RSS feeds.'); ?></p> </td> </tr> -</table> -</fieldset> -<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> + <tr valign="top"> -<th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th> +<th scope="row"><?php _e('Encoding for pages and feeds') ?></th> <td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option('blog_charset'); ?>" size="20" class="code" /><br /> <?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td> </tr> </table> <p class="submit"> <input type="hidden" name="action" value="update" /> -<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> +<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index d291e5f..5734415 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -1,26 +1,25 @@ <?php require_once('admin.php'); -$title = __('Writing Options'); +$title = __('Writing Settings'); $parent_file = 'options-general.php'; include('admin-header.php'); ?> <div class="wrap"> -<h2><?php _e('Writing Options') ?></h2> +<h2><?php _e('Writing Settings') ?></h2> <form method="post" action="options.php"> <?php wp_nonce_field('writing-options') ?> <input type='hidden' name='option_page' value='writing' /> -<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /></p> -<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> +<table class="form-table"> <tr valign="top"> -<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th> -<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em; " /> +<th scope="row"> <?php _e('Size of the post box') ?></th> +<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em;" /> <?php _e('lines') ?></td> </tr> <tr valign="top"> -<th scope="row"><?php _e('Formatting:') ?></th> +<th scope="row"><?php _e('Formatting') ?></th> <td> <label for="use_smilies"> <input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', get_option('use_smilies')); ?> /> @@ -29,7 +28,7 @@ include('admin-header.php'); </td> </tr> <tr valign="top"> -<th scope="row"><?php _e('Default post category:') ?></th> +<th scope="row"><?php _e('Default Post Category') ?></th> <td><select name="default_category" id="default_category"> <?php $categories = get_categories('get=all'); @@ -43,7 +42,7 @@ endforeach; </select></td> </tr> <tr valign="top"> -<th scope="row"><?php _e('Default link category:') ?></th> +<th scope="row"><?php _e('Default Link Category') ?></th> <td><select name="default_link_category" id="default_link_category"> <?php $link_categories = get_terms('link_category', 'get=all'); @@ -59,12 +58,9 @@ endforeach; </table> - -</fieldset> - <p class="submit"> <input type="hidden" name="action" value="update" /> -<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> +<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> diff --git a/wp-admin/options.php b/wp-admin/options.php index eb4eb04..017f2a2 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -1,7 +1,7 @@ <?php require_once('admin.php'); -$title = __('Options'); +$title = __('Settings'); $this_file = 'options.php'; $parent_file = 'options-general.php'; @@ -9,8 +9,8 @@ wp_reset_vars(array('action')); $whitelist_options = array( 'general' => array('siteurl', 'home', 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'comment_registration', 'default_role'), - 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys' ), - 'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path' ), + 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating' ), + 'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h' ), 'privacy' => array( 'blog_public' ), 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'gzipcompression', 'show_on_front', 'page_on_front', 'page_for_posts' ), 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'ping_sites', 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category' ), @@ -63,7 +63,7 @@ case 'update': $option = trim($option); $value = $_POST[$option]; if(!is_array($value)) $value = trim($value); - $value = stripslashes_deep($value); + $value = stripslashes_deep($value); update_option($option, $value); } } @@ -79,13 +79,12 @@ default: include('admin-header.php'); ?> <div class="wrap"> - <h2><?php _e('All Options'); ?></h2> + <h2><?php _e('All Settings'); ?></h2> <form name="form" action="options.php" method="post" id="all-options"> <?php wp_nonce_field('options-options') ?> <input type="hidden" name="action" value="update" /> <input type='hidden' name='option_page' value='options' /> - <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Options »') ?>" /></p> - <table width="98%"> + <table class="form-table"> <?php $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); @@ -124,7 +123,7 @@ endforeach; ?> </table> <?php $options_to_update = implode(',', $options_to_update); ?> -<p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Update Options »') ?>" /></p> +<p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Save Changes') ?>" /></p> </form> </div> diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php index ff86155..f09d657 100644 --- a/wp-admin/page-new.php +++ b/wp-admin/page-new.php @@ -3,21 +3,24 @@ require_once('admin.php'); $title = __('New Page'); $parent_file = 'post-new.php'; $editing = true; -wp_enqueue_script('prototype'); -wp_enqueue_script('interface'); wp_enqueue_script('autosave'); +wp_enqueue_script('page'); +if ( user_can_richedit() ) + wp_enqueue_script('editor'); +wp_enqueue_script('thickbox'); +wp_enqueue_script('media-upload'); + require_once('admin-header.php'); ?> <?php if ( (isset($_GET['posted']) && $_GET['posted']) || isset($_GET['saved']) ) : ?> -<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page »') ; ?></a></p></div> +<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page') ; ?></a></p></div> <?php endif; ?> <?php if ( current_user_can('edit_pages') ) { $action = 'post'; - $post = get_default_post_to_edit(); - $post->post_type = 'page'; + $post = get_default_page_to_edit(); include('edit-page-form.php'); } diff --git a/wp-admin/page.php b/wp-admin/page.php index 7a373e9..6f755da 100644 --- a/wp-admin/page.php +++ b/wp-admin/page.php @@ -7,6 +7,48 @@ $submenu_file = 'edit-pages.php'; $wp_rewrite->flush_rules(); wp_reset_vars(array('action')); +function redirect_page($page_ID) { + $referredby = ''; + if ( !empty($_POST['referredby']) ) + $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); + $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); + + if ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) { + $location = $_POST['referredby']; + } elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { + $location = 'sidebar.php?a=b'; + } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) { + if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page-new.php') === false ) + $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "page.php?action=edit&post=$page_ID&message=1" ); + else + $location = "page.php?action=edit&post=$page_ID&message=4"; + } elseif ($_POST['addmeta']) { + $location = add_query_arg( 'message', 2, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif ($_POST['deletemeta']) { + $location = add_query_arg( 'message', 3, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif (!empty($referredby) && $referredby != $referer) { + $location = $_POST['referredby']; + if ( $_POST['referredby'] == 'redo' ) + $location = get_permalink( $page_ID ); + elseif ( false !== strpos($location, 'edit-pages.php') ) + $location = add_query_arg('posted', $page_ID, $location); + elseif ( false !== strpos($location, 'wp-admin') ) + $location = "page-new.php?posted=$page_ID"; + } elseif ( isset($_POST['publish']) ) { + $location = "page-new.php?posted=$page_ID"; + } elseif ($action == 'editattachment') { + $location = 'attachments.php'; + } else { + $location = "page.php?action=edit&post=$page_ID&message=4"; + } + + wp_redirect($location); +} + if (isset($_POST['deletepost'])) { $action = "delete"; } @@ -16,27 +58,8 @@ case 'post': check_admin_referer('add-page'); $page_ID = write_post(); - // Redirect. - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'page-new.php'; - break; - } - } else { - $location = "page-new.php?posted=$page_ID"; - } - - if ( isset($_POST['save']) ) - $location = "page.php?action=edit&post=$page_ID"; + redirect_page($page_ID); - wp_redirect($location); exit(); break; @@ -53,11 +76,22 @@ case 'edit': exit(); } - if($post->post_status == 'draft') { - wp_enqueue_script('prototype'); - wp_enqueue_script('interface'); + wp_enqueue_script('page'); + if ( user_can_richedit() ) + wp_enqueue_script('editor'); + wp_enqueue_script('thickbox'); + wp_enqueue_script('media-upload'); + if ( $last = wp_check_post_lock( $post->ID ) ) { + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); + $message = sprintf( __( 'Warning: %s is currently editing this page' ), wp_specialchars( $last_user_name ) ); + $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" ); + add_action('admin_notices', create_function( '', "echo '$message';" ) ); + } else { + wp_set_post_lock( $post->ID ); wp_enqueue_script('autosave'); } + require_once('admin-header.php'); if ( !current_user_can('edit_page', $page_ID) ) @@ -86,43 +120,7 @@ case 'editpost': $page_ID = edit_post(); - if ( 'post' == $_POST['originalaction'] ) { - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'page-new.php'; - break; - } - } else { - $location = "page-new.php?posted=$page_ID"; - } - - if ( isset($_POST['save']) ) - $location = "page.php?action=edit&post=$page_ID"; - } else { - if ($_POST['save']) { - $location = "page.php?action=edit&post=$page_ID"; - } elseif ($_POST['updatemeta']) { - $location = wp_get_referer() . '&message=2#postcustom'; - } elseif ($_POST['deletemeta']) { - $location = wp_get_referer() . '&message=3#postcustom'; - } elseif (!empty($_POST['referredby']) && $_POST['referredby'] != wp_get_referer()) { - $location = $_POST['referredby']; - if ( $_POST['referredby'] == 'redo' ) - $location = get_permalink( $page_ID ); - } elseif ($action == 'editattachment') { - $location = 'attachments.php'; - } else { - $location = 'page-new.php'; - } - } - wp_redirect($location); // Send user on their way while we keep working + redirect_page($page_ID); exit(); break; diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index e9fc912..f84daa1 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -7,12 +7,16 @@ $parent_file = 'plugins.php'; wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); +add_action( 'admin_head', 'theme_editor_css' ); +function theme_editor_css(){ + wp_admin_css( 'css/theme-editor' ); +} + $plugins = get_plugins(); $plugin_files = array_keys($plugins); -if (empty($file)) { +if (empty($file)) $file = $plugin_files[0]; -} $file = validate_file_to_edit($file, $plugin_files); $real_file = get_real_file_to_edit( PLUGINDIR . "/$file"); @@ -27,27 +31,23 @@ case 'update': wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>'); $newcontent = stripslashes($_POST['newcontent']); - if (is_writeable($real_file)) { + if ( is_writeable($real_file) ) { $f = fopen($real_file, 'w+'); fwrite($f, $newcontent); fclose($f); // Deactivate so we can test it. - $current = get_option('active_plugins'); - if ( in_array($file, $current) || isset($_POST['phperror']) ) { - if ( in_array($file, $current) ) { - array_splice($current, array_search( $file, $current), 1 ); // Array-fu! - update_option('active_plugins', $current); - } + if ( is_plugin_active($file) || isset($_POST['phperror']) ) { + if ( is_plugin_active($file) ) + deactivate_plugins($file, true); wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); - exit(); + exit; } wp_redirect("plugin-editor.php?file=$file&a=te"); } else { wp_redirect("plugin-editor.php?file=$file"); } - - exit(); + exit; break; @@ -56,73 +56,75 @@ default: if ( !current_user_can('edit_plugins') ) wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>'); - if ( $_GET['liveupdate'] ) { + if ( isset($_GET['liveupdate']) ) { check_admin_referer('edit-plugin-test_' . $file); - $current = get_option('active_plugins'); - $plugin = $file; - if ( validate_file($plugin) ) - wp_die(__('Invalid plugin.')); - if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) - wp_die(__('Plugin file does not exist.')); - if (!in_array($plugin, $current)) { - wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error - @include(ABSPATH . PLUGINDIR . '/' . $plugin); - $current[] = $plugin; - sort($current); - update_option('active_plugins', $current); - } + + $error = validate_plugin($file); + if( is_wp_error($error) ) + wp_die( $error ); + + if ( ! is_plugin_active($file) ) + activate_plugin($file, "plugin-editor.php?file=$file&phperror=1");// we'll override this later if the plugin can be included without fatal error + wp_redirect("plugin-editor.php?file=$file&a=te"); + exit; } require_once('admin-header.php'); update_recently_edited(PLUGINDIR . "/$file"); - if (!is_file($real_file)) + if ( ! is_file($real_file) ) $error = 1; - if (!$error) { - $f = fopen($real_file, 'r'); - $content = fread($f, filesize($real_file)); - $content = htmlspecialchars($content); - } + if ( ! $error ) + $content = htmlspecialchars(file_get_contents($real_file)); ?> <?php if (isset($_GET['a'])) : ?> <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> <?php elseif (isset($_GET['phperror'])) : ?> - <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p></div> + <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p> + <?php + if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?> + <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo attribute_escape($file); ?>&_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe> + <?php } ?> +</div> <?php endif; ?> <div class="wrap"> - <?php - if ( in_array($file, (array) get_option('active_plugins')) ) { - if (is_writeable($real_file)) { - echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (active)'), $file) . '</h2>'; - } else { - echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (active)'), $file) . '</h2>'; - } +<div class="bordertitle"> + <h2><?php _e('Plugin Editor'); ?></h2> +</div> +<div class="tablenav"> +<div class="alignleft"> +<big><strong><?php + if ( is_plugin_active($file) ) { + if ( is_writeable($real_file) ) + echo sprintf(__('Editing <strong>%s</strong> (active)'), $file); + else + echo sprintf(__('Browsing <strong>%s</strong> (active)'), $file); } else { - if (is_writeable($real_file)) { - echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (inactive)'), $file) . '</h2>'; - } else { - echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file) . '</h2>'; - } + if ( is_writeable($real_file) ) + echo sprintf(__('Editing <strong>%s</strong> (inactive)'), $file); + else + echo sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file); } - ?> + ?></strong></big> +</div> +<br class="clear" /> +</div> +<br class="clear" /> <div id="templateside"> -<h3><?php _e('Plugin files') ?></h3> + <h3 id="bordertitle"><?php _e('Plugin Files'); ?></h3> -<?php -if ($plugin_files) : -?> + <h4><?php _e('Plugins'); ?></h4> <ul> - <?php foreach($plugin_files as $plugin_file) : ?> - <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li> - <?php endforeach; ?> +<?php foreach($plugin_files as $plugin_file) : ?> + <li><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li> +<?php endforeach; ?> </ul> -<?php endif; ?> -</div> -<?php if (!$error) { ?> + </div> +<?php if ( ! $error ) { ?> <form name="template" id="template" action="plugin-editor.php" method="post"> <?php wp_nonce_field('edit-plugin_' . $file) ?> <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea> @@ -136,13 +138,13 @@ if ($plugin_files) : <p class="submit"> <?php if ( isset($_GET['phperror']) ) - echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate »') . "' tabindex='2' />"; + echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate') . "' tabindex='2' />"; else - echo "<input type='submit' name='submit' value='" . __('Update File »') . "' tabindex='2' />"; + echo "<input type='submit' name='submit' value='" . __('Update File') . "' tabindex='2' />"; ?> </p> <?php else : ?> - <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p> + <p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p> <?php endif; ?> </form> <?php @@ -153,7 +155,6 @@ if ($plugin_files) : <div class="clear"> </div> </div> <?php -break; + break; } - include("admin-footer.php") ?> diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 8593424..1cd1a89 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -9,100 +9,67 @@ if( $menu_perms[ 'plugins' ] != 1 ) return; if ( isset($_GET['action']) ) { - if ('activate' == $_GET['action']) { - check_admin_referer('activate-plugin_' . $_GET['plugin']); - $current = get_option('active_plugins'); + if ( isset($_GET['plugin']) ) $plugin = trim($_GET['plugin']); - if ( validate_file($plugin) ) - wp_die(__('Invalid plugin.')); - if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) - wp_die(__('Plugin file does not exist.')); - if (!in_array($plugin, $current)) { - wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error - ob_start(); - @include(ABSPATH . PLUGINDIR . '/' . $plugin); - $current[] = $plugin; - sort($current); - update_option('active_plugins', $current); - do_action('activate_' . $plugin); - ob_end_clean(); - } + + if ( 'activate' == $_GET['action'] ) { + check_admin_referer('activate-plugin_' . $_GET['plugin']); + $result = activate_plugin($_GET['plugin'], 'plugins.php?error=true&plugin=' . $plugin); + if ( is_wp_error( $result ) ) + wp_die( $result->get_error_message() ); wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above - } elseif ('error_scrape' == $_GET['action']) { - $plugin = trim($_GET['plugin']); + } elseif ( 'error_scrape' == $_GET['action'] ) { check_admin_referer('plugin-activation-error_' . $plugin); - if ( validate_file($plugin) ) - wp_die(__('Invalid plugin.')); - if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) - wp_die(__('Plugin file does not exist.')); + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + wp_die($valid); + error_reporting( E_ALL ^ E_NOTICE ); + @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. include(ABSPATH . PLUGINDIR . '/' . $plugin); - } elseif ('deactivate' == $_GET['action']) { + } elseif ( 'deactivate' == $_GET['action'] ) { check_admin_referer('deactivate-plugin_' . $_GET['plugin']); - $current = get_option('active_plugins'); - array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu! - update_option('active_plugins', $current); - do_action('deactivate_' . trim( $_GET['plugin'] )); + deactivate_plugins($_GET['plugin']); wp_redirect('plugins.php?deactivate=true'); - } elseif ($_GET['action'] == 'deactivate-all') { + } elseif ( 'deactivate-all' == $_GET['action'] ) { check_admin_referer('deactivate-all'); - $current = get_option('active_plugins'); - - foreach ($current as $plugin) { - array_splice($current, array_search($plugin, $current), 1); - do_action('deactivate_' . $plugin); - } - - update_option('active_plugins', array()); + deactivate_all_plugins(); wp_redirect('plugins.php?deactivate-all=true'); + } elseif ('reactivate-all' == $_GET['action']) { + check_admin_referer('reactivate-all'); + reactivate_all_plugins('plugins.php?errors=true'); + wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above } + exit; } $title = __('Manage Plugins'); require_once('admin-header.php'); -// Clean up options -// If any plugins don't exist, axe 'em +validate_active_plugins(); -$check_plugins = get_option('active_plugins'); - -// Sanity check. If the active plugin list is not an array, make it an -// empty array. -if ( !is_array($check_plugins) ) { - $check_plugins = array(); - update_option('active_plugins', $check_plugins); -} - -// If a plugin file does not exist, remove it from the list of active -// plugins. -foreach ($check_plugins as $check_plugin) { - if (!file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin)) { - $current = get_option('active_plugins'); - $key = array_search($check_plugin, $current); - if ( false !== $key && NULL !== $key ) { - unset($current[$key]); - update_option('active_plugins', $current); - } - } -} ?> <?php if ( isset($_GET['error']) ) : ?> <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p> <?php $plugin = trim($_GET['plugin']); - if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) && 1 == strtolower(ini_get('display_errors'))) { ?> + if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo attribute_escape($plugin); ?>&_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe> <?php } ?> </div> +<?php elseif ( isset($_GET['errors']) ) : ?> + <div id="message" class="updated fade"><p><?php _e('Some plugins could not be reactivated because they triggered a <strong>fatal error</strong>.') ?></p></div> <?php elseif ( isset($_GET['activate']) ) : ?> <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div> <?php elseif ( isset($_GET['deactivate']) ) : ?> <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div> <?php elseif (isset($_GET['deactivate-all'])) : ?> <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div> +<?php elseif (isset($_GET['reactivate-all'])) : ?> + <div id="message" class="updated fade"><p><?php _e('Plugins <strong>reactivated</strong>.'); ?></p></div> <?php endif; ?> <div class="wrap"> @@ -110,9 +77,6 @@ foreach ($check_plugins as $check_plugin) { <p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p> <?php -if ( get_option('active_plugins') ) - $current_plugins = get_option('active_plugins'); - $plugins = get_plugins(); if (empty($plugins)) { @@ -121,26 +85,50 @@ if (empty($plugins)) { echo '</p>'; } else { ?> -<table class="widefat plugins"> + +<div class="tablenav"> + <div class="alignleft"> + <?php + $active = get_option('active_plugins'); + $inactive = get_option('deactivated_plugins'); + if ( !empty($active) ) { + ?> + <a class="button-secondary" href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a> + <?php + } elseif ( empty($active) && !empty($inactive) ) { + ?> + <a class="button-secondary" href="<?php echo wp_nonce_url('plugins.php?action=reactivate-all', 'reactivate-all'); ?>" class="delete"><?php _e('Reactivate Plugins'); ?></a> + <?php + } // endif active/inactive plugin check + ?> + </div> + <br class="clear" /> +</div> + +<br class="clear" /> + +<table class="widefat"> <thead> <tr> <th><?php _e('Plugin'); ?></th> - <th style="text-align: center"><?php _e('Version'); ?></th> + <th class="num"><?php _e('Version'); ?></th> <th><?php _e('Description'); ?></th> + <th class="status"><?php _e('Status') ?></th> + <th class="action-links"><?php _e('Action'); ?></th> </tr> </thead> + <tbody id="plugins"> <?php - $style = ''; - foreach($plugins as $plugin_file => $plugin_data) { - $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; + $action_links = array(); + + $style = ''; - if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { - $toggle = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; - $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>"; - $style .= $style == 'alternate' ? ' active' : 'active'; + if ( is_plugin_active($plugin_file) ) { + $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; + $style = 'active'; } else { - $toggle = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; + $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; } $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); @@ -150,29 +138,35 @@ if (empty($plugins)) { $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); + $author = ( empty($plugin_data['Author']) ) ? '' : ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; if ( $style != '' ) - $style = 'class="' . $style . '"'; - $author = ( empty($plugin_data['Author']) ) ? '' : ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; + $style = ' class="' . $style . '"'; + + $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_info); echo " - <tr $style> + <tr$style> <td class='name'>{$plugin_data['Title']}</td> <td class='vers'>{$plugin_data['Version']}</td> <td class='desc'><p>{$plugin_data['Description']}$author</p></td> - <td class='togl'>$toggle</td>"; - echo" + <td class='status'>"; + if ( is_plugin_active($plugin_file) ) + echo __('<span class="active">Active</span>'); + else + _e('<span class="inactive">Inactive</span>'); + echo "</td> + <td class='togl action-links'>$toggle"; + if ( !empty($action_links) ) + echo implode(' | ', $action_links); + echo "</td> </tr>"; do_action( 'after_plugin_row', $plugin_file ); } ?> - -<tr> - <td colspan="3"> </td> - <td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td> -</tr> - + </tbody> </table> + <?php } ?> diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index c6b709b..263783a 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -3,9 +3,13 @@ require_once('admin.php'); $title = __('Create New Post'); $parent_file = 'post-new.php'; $editing = true; -wp_enqueue_script('prototype'); -wp_enqueue_script('interface'); wp_enqueue_script('autosave'); +wp_enqueue_script('post'); +if ( user_can_richedit() ) + wp_enqueue_script('editor'); +wp_enqueue_script('thickbox'); +wp_enqueue_script('media-upload'); + require_once ('./admin-header.php'); if ( ! current_user_can('edit_posts') ) { ?> @@ -20,109 +24,18 @@ When you’re promoted, just reload this page and you’ll be able to bl exit(); } -if ( isset($_GET['posted']) && $_GET['posted'] ) : ?> -<div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post »'); ?></a></p></div> +if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> +<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit post'); ?></a></p></div> <?php endif; ?> <?php -$my_drafts = get_users_drafts($user_ID); -$pending = get_others_pending($user_ID); -$others_drafts = get_others_drafts($user_ID); - -$nag_posts_limit = (int) apply_filters('nag_posts_limit', 3); - -$nag_posts = array( - array( - 'my_drafts', - __('Your Drafts:'), - 'edit.php?post_status=draft&author=' . $user_ID, - count($my_drafts)), - array( - 'pending', - __('Pending Review:'), - 'edit.php?post_status=pending', - count($pending)), - array( - 'others_drafts', - __('Others’ Drafts:'), - 'edit.php?post_status=draft&author=-' . $user_ID, - count($others_drafts)) - ); - -if ( !empty($my_drafts) || !empty($pending) || !empty($others_drafts) ) { - echo '<div class="wrap" id="draft-nag">'; - - foreach ( $nag_posts as $nag ) { - if ( ${$nag[0]} ) { - echo '<p><strong>' . wp_specialchars($nag[1]) . '</strong> '; - $i = 0; - foreach ( ${$nag[0]} as $post ) { - $i++; - if ( $i > $nag_posts_limit ) - break; - echo '<a href="post.php?action=edit&post=' . $post->ID . '">'; - ( '' == the_title('', '', FALSE) ) ? printf( __('Post #%s'), $post->ID ) : the_title(); - echo '</a>'; - if ( $i < min($nag[3], $nag_posts_limit) ) - echo ', '; - } - if ( $nag[3] > $nag_posts_limit ) - printf(__(', and <a href="%s">%d more</a>'), $nag[2], $nag[3] - $nag_posts_limit); - echo '.</p>'; - } - } - echo "</div>\n"; -} -?> - -<?php // Show post form. $post = get_default_post_to_edit(); include('edit-form-advanced.php'); -?> -<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?> -<div id="wp-bookmarklet" class="wrap"> -<h3><?php _e('WordPress Bookmarklet'); ?></h3> -<p><?php _e('Right click on the following link and choose “Bookmark This Link...” or “Add to Favorites...” to create a posting shortcut.'); ?></p> -<p> - -<?php -if ($is_NS4 || $is_gecko) { +include('admin-footer.php'); ?> -<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), get_bloginfo('name', 'display')); ?></a> -<?php -} else if ($is_winIE) { -?> -<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_bloginfo('name', 'display')); ?></a> -<script type="text/javascript"> -<!-- -function oneclickbookmarklet(blah) { -window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120"); -} -// --> -</script> -<br /> -<br /> -<?php _e('One-click bookmarklet:') ?><br /> -<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a> -<?php -} else if ($is_opera) { -?> -<a href="javascript:location.href='<?php echo get_option('siteurl'); ?>/wp-admin/post-new.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a> -<?php -} else if ($is_macIE) { -?> -<a href="javascript:Q='';location.href='<?php echo get_option('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a> -<?php -} -?> -</p> -</div> -<?php } ?> - -<?php include('admin-footer.php'); ?> diff --git a/wp-admin/post.php b/wp-admin/post.php index 680f8ab..66e0ab7 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -6,48 +6,72 @@ $submenu_file = 'edit.php'; wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); +function redirect_post($post_ID = '') { + global $action; + + $referredby = ''; + if ( !empty($_POST['referredby']) ) + $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); + $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); + + if ( !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) { + $location = $_POST['referredby']; + } elseif ( !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { + $location = 'sidebar.php?a=b'; + } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) { + if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false ) + $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" ); + else + $location = "post.php?action=edit&post=$post_ID&message=4"; + } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { + $location = add_query_arg( 'message', 2, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { + $location = add_query_arg( 'message', 3, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif (!empty($referredby) && $referredby != $referer) { + $location = $_POST['referredby']; + if ( $_POST['referredby'] == 'redo' ) + $location = get_permalink( $post_ID ); + elseif ( false !== strpos($location, 'edit.php') ) + $location = add_query_arg('posted', $post_ID, $location); + elseif ( false !== strpos($location, 'wp-admin') ) + $location = "post-new.php?posted=$post_ID"; + } elseif ( isset($_POST['publish']) ) { + $location = "post-new.php?posted=$post_ID"; + } elseif ($action == 'editattachment') { + $location = 'attachments.php'; + } else { + $location = "post.php?action=edit&post=$post_ID&message=4"; + } + + wp_redirect( $location ); +} + if ( isset( $_POST['deletepost'] ) ) $action = 'delete'; switch($action) { case 'postajaxpost': case 'post': - $parent_file = 'post-new.php'; - $submenu_file = 'post-new.php'; check_admin_referer('add-post'); $post_ID = 'post' == $action ? write_post() : edit_post(); - // Redirect. - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'post-new.php'; - break; - } - } else { - $location = "post-new.php?posted=$post_ID"; - } - - if ( isset($_POST['save']) ) - $location = "post.php?action=edit&post=$post_ID"; - - if ( empty($post_ID) ) - $location = 'post-new.php'; - - wp_redirect($location); + redirect_post($post_ID); exit(); break; case 'edit': $title = __('Edit'); $editing = true; + + if ( empty( $_GET['post'] ) ) { + wp_redirect("post.php"); + exit(); + } $post_ID = $p = (int) $_GET['post']; $post = get_post($post_ID); @@ -58,10 +82,22 @@ case 'edit': exit(); } - if($post->post_status == 'draft') { - wp_enqueue_script('prototype'); + wp_enqueue_script('post'); + if ( user_can_richedit() ) + wp_enqueue_script('editor'); + wp_enqueue_script('thickbox'); + wp_enqueue_script('media-upload'); + if ( $last = wp_check_post_lock( $post->ID ) ) { + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); + $message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) ); + $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" ); + add_action('admin_notices', create_function( '', "echo '$message';" ) ); + } else { + wp_set_post_lock( $post->ID ); wp_enqueue_script('autosave'); } + require_once('admin-header.php'); if ( !current_user_can('edit_post', $post_ID) ) @@ -94,49 +130,7 @@ case 'editpost': $post_ID = edit_post(); - if ( 'post' == $_POST['originalaction'] ) { - if (!empty($_POST['mode'])) { - switch($_POST['mode']) { - case 'bookmarklet': - $location = $_POST['referredby']; - break; - case 'sidebar': - $location = 'sidebar.php?a=b'; - break; - default: - $location = 'post-new.php'; - break; - } - } else { - $location = "post-new.php?posted=$post_ID"; - } - - if ( isset($_POST['save']) ) - $location = "post.php?action=edit&post=$post_ID"; - } else { - $referredby = ''; - if ( !empty($_POST['referredby']) ) - $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); - $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); - - if ($_POST['save']) { - $location = "post.php?action=edit&post=$post_ID"; - } elseif ($_POST['updatemeta']) { - $location = wp_get_referer() . '&message=2#postcustom'; - } elseif ($_POST['deletemeta']) { - $location = wp_get_referer() . '&message=3#postcustom'; - } elseif (!empty($referredby) && $referredby != $referer) { - $location = $_POST['referredby']; - if ( $_POST['referredby'] == 'redo' ) - $location = get_permalink( $post_ID ); - } elseif ($action == 'editattachment') { - $location = 'attachments.php'; - } else { - $location = 'post-new.php'; - } - } - - wp_redirect($location); // Send user on their way while we keep working + redirect_post($post_ID); // Send user on their way while we keep working exit(); break; diff --git a/wp-admin/profile.php b/wp-admin/profile.php index 53d82b6..685d46c 100644 --- a/wp-admin/profile.php +++ b/wp-admin/profile.php @@ -1,150 +1,4 @@ <?php -require_once('admin.php'); - -$title = __('Profile'); - -if ( current_user_can('edit_users') ) - $parent_file = 'users.php'; -else - $parent_file = 'profile.php'; -include_once('admin-header.php'); -$profileuser = get_user_to_edit($user_ID); - -$bookmarklet_height= 440; +define('IS_PROFILE_PAGE', true); +require_once('user-edit.php'); ?> - -<?php if ( isset($_GET['updated']) ) { ?> -<div id="message" class="updated fade"> -<p><strong><?php _e('Profile updated.') ?></strong></p> -</div> -<?php } ?> - -<div class="wrap"> -<h2><?php _e('Your Profile and Personal Options'); ?></h2> -<form name="profile" id="your-profile" action="profile-update.php" method="post"> -<?php wp_nonce_field('update-profile_' . $user_ID) ?> -<p> -<input type="hidden" name="from" value="profile" /> -<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> -</p> - -<h3><?php _e('Personal Options'); ?></h3> - -<?php if ( rich_edit_exists() && current_user_can( 'edit_posts' ) ) : // don't bother showing the option if the editor has been removed ?> -<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> /> -<?php _e('Use the visual editor when writing') ?></label></p> -<?php endif; ?> - -<?php do_action('profile_personal_options'); ?> - -<p class="submit"><input type="submit" value="<?php _e('Update Profile »') ?>" name="submit" /></p> - -<fieldset id="information"> -<legend><?php _e('Name'); ?></legend> -<p><label><?php _e('Username: (no editing)'); ?><br /> -<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" /> -</label></p> - -<p><label><?php _e('First name:') ?><br /> -<input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></label></p> - -<p><label><?php _e('Last name:') ?><br /> -<input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" /></label></p> - -<p><label><?php _e('Nickname:') ?><br /> -<input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p> - -<p><label><?php _e('Display name publicly as:') ?> <br /> -<select name="display_name" id="display_name"> -<option value="<?php echo $profileuser->display_name; ?>"><?php echo $profileuser->display_name; ?></option> -<option value="<?php echo $profileuser->nickname ?>"><?php echo $profileuser->nickname ?></option> -<option value="<?php echo $profileuser->user_login ?>"><?php echo $profileuser->user_login ?></option> -<?php if ( !empty( $profileuser->first_name ) ) : ?> -<option value="<?php echo $profileuser->first_name ?>"><?php echo $profileuser->first_name ?></option> -<?php endif; ?> -<?php if ( !empty( $profileuser->last_name ) ) : ?> -<option value="<?php echo $profileuser->last_name ?>"><?php echo $profileuser->last_name ?></option> -<?php endif; ?> -<?php if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) : ?> -<option value="<?php echo $profileuser->first_name." ".$profileuser->last_name ?>"><?php echo $profileuser->first_name." ".$profileuser->last_name ?></option> -<option value="<?php echo $profileuser->last_name." ".$profileuser->first_name ?>"><?php echo $profileuser->last_name." ".$profileuser->first_name ?></option> -<?php endif; ?> -</select></label></p> -</fieldset> - -<fieldset id="contact-info"> -<legend><?php _e('Contact Info'); ?></legend> - -<p><label><?php _e('E-mail: (required)') ?><br /> -<input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /></label></p> - -<p><label><?php _e('Website:') ?><br /> -<input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" /> -</label></p> - -<p><label><?php _e('AIM:') ?><br /> -<input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" /> -</label></p> - -<p><label><?php _e('Yahoo IM:') ?><br /> -<input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" /> -</label></p> - -<p><label><?php _e('Jabber / Google Talk:') ?><br /> -<input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></label> -</p> -</fieldset> -<br clear="all" /> -<fieldset id="about-yourself"> -<legend><?php _e('About Yourself'); ?></legend> -<p class="desc"><?php _e('Share a little biographical information. '); ?></p> -<p><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p> -</fieldset> - -<?php -$show_password_fields = apply_filters('show_password_fields', true); -if ( $show_password_fields ) : -?> -<fieldset id="update-password"> -<legend><?php _e('Update Your Password'); ?></legend> -<p class="desc"><?php _e('If you would like to change your password type a new one twice below. Otherwise leave this blank.'); ?></p> -<p><label><?php _e('New Password:'); ?><br /> -<input type="password" name="pass1" id="pass1" size="16" value="" /> -</label></p> -<p><label><?php _e('Type it one more time:'); ?><br /> -<input type="password" name="pass2" id="pass2" size="16" value="" /> -</label></p> -</fieldset> -<?php endif; ?> - -<?php do_action('show_user_profile'); ?> - -<br clear="all" /> - - <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform"> - <?php - if(count($profileuser->caps) > count($profileuser->roles)): - ?> - <tr> - <th scope="row"><?php _e('Additional Capabilities:') ?></th> - <td><?php - $output = ''; - foreach($profileuser->caps as $cap => $value) { - if(!$wp_roles->is_role($cap)) { - if($output != '') $output .= ', '; - $output .= $value ? $cap : "Denied: {$cap}"; - } - } - echo $output; - ?></td> - </tr> - <?php - endif; - ?> - </table> -<p class="submit"><input type="submit" value="<?php _e('Update Profile »') ?>" name="submit" /></p> -</form> - -</div> - -<?php include('admin-footer.php'); ?> diff --git a/wp-admin/rtl.css b/wp-admin/rtl.css index 0dd46f6..e5d9fb8 100644 --- a/wp-admin/rtl.css +++ b/wp-admin/rtl.css @@ -1,133 +1,314 @@ -html, -.dbx-handle, -#post_name, -input[name=link_url], -input[name=link_image], -input[name=opml_url], -input[name=file], -input#rss_uri, -#template #newcontent, -#devnews, -#planetnews, -#content, -body.login #login a, -#newcomment_author_url, -#email { +html,#edit-slug-box,#trackback,#category_nicename,#slug,#dbuser,#dbpass,#dbname,#dbhost,#dbprefix,#dccharset,input[name=gmpath],input[name=archivespath],input[name=lastentry],input[name=email],input[name=url],input[name=aim],input[name=yim],input[name=jabber],#newcontent,#email,#newcomment_author_url,#pass1,#pass2,#siteurl,#home,#admin_email,#date_format,#time_format,#mailserver_url,#mailserver_login,#mailserver_pass,#ping_sites,#blog_charset,#moderation_keys,#blacklist_keys,#permalink_structure,#category_base,#tag_base,#upload_path,#upload_url_path,#insertonly[src],#insertonly[href],#mailserver_port,#thumbnail_size_w,#thumbnail_size_h,#medium_size_w,#medium_size_h,#posts_per_page,#posts_per_rss,#comment_max_links,#insertonly[src],#link_url,#link_image,#rss_uri,#user_login,#key +{ + direction:ltr; + text-align:left +} + +body, td { + font-family: Tahoma,Verdana,sans-serif; +} + +#wpwrap,#footer,#TB_title,.media-upload-form,#media-upload-header +{ + direction:rtl!important; + text-align:right!important +} + +#user_info +{ + left:15px; + right:auto +} + +#wphead h1 +{ + margin:0 0 0 15%; + padding:11px 15px 16px 170px +} + +#wphead #viewsite +{ + margin-left:0; + margin-right:10px +} + +#sidemenu +{ + float:left; + margin:-30px 315px 0 15px; + padding-left:0; + padding-right:10px +} + +#dashmenu +{ + font-size:11px; + left:auto; + padding-left:0; + padding-right:9px; + right:0 +} + +#dashmenu a +{ + margin-left:8px; + margin-right:8px; +} + +#adminmenu +{ + height:32px; + padding:5px 8px 0 0 +} + +#adminmenu li a +{ + display:block; + float:right; + font:700 16px/100% "Times New Roman", Times, serif; + margin:0 0 0 10px; + padding:5px 7px 9px +} + +#adminmenu li a.current +{ + font-weight:700 +} + +#adminmenu li a #awaiting-mod +{ + background:url(images/comment-stalk-rtl.gif) -309px bottom !important; + font-family: Tahoma, Verdana, sans-serif; + margin-left:-45px; + margin-right:.2em; + margin-top:-5px +} + +#adminmenu li a:hover #awaiting-mod +{ + background-position: -229px bottom !important; +} + +#adminmenu li a #awaiting-mod span +{ + left:0; + right:auto +} + +#submenu li a +{ + display:block; + float:right; + margin:0 10px 10px 0; + padding:2px 4px +} + +p#post-search +{ + left:0; + right:auto +} + +.tablenav div +{ + float:right!important +} + +ul.view-switch +{ + float:left; + margin:-28px 0 -2px 5px +} + +#currenttheme img +{ + float:right; + margin-left:1em; + margin-right:0 +} + +form#themeselector +{ + float:left +} + +.form-table input.tog +{ + float:right; + margin-right:0; + margin-left:2px; +} + +.curtime +{ + background-position:right 2px; + padding-left:0; + padding-right:18px; +} + +#poststuff #edButtonPreview,#poststuff #edButtonHTML +{ + float:left; + margin-left:8px; + margin-right:0 +} + +#poststuff #media-buttons +{ direction: ltr; - } -#adminmenu, -#submenu, -#minisub, -.wrap, -.updated, -.confirm, -#devnews h3, -#planetnews h3, -#wphead, -#user_info, -body.login, -#login_error { - direction: rtl; - } -p.submit, -.dbx-handle { - text-align: left; - } -html *, -select, -input, -table * { - font-family: tahoma, Tahoma, "Times New Roman", Times, serif; - } -#wphead { - padding: .8em 2em .8em 19em; - } -#user_info { - right: auto; - left: 1em; - } -#adminmenu { - padding: .2em 2em .3em .2em; - height: 28px; - } -* html #adminmenu { - padding-bottom: 0; - } -#adminmenu a { - margin: 0 0 0 10px; - display: block; + float:left; + margin-left:20px; + margin-right:0 +} + +#poststuff #media-buttons a +{ + margin-left:8px; + margin-right:0; + padding: 0 5px 2px 2px; +} + +#poststuff .togbox +{ + margin-left:0; + margin-right:-19px +} + +#categorydiv ul#category-tabs,#linkcategorydiv ul#category-tabs +{ + float:right; + margin:0 0 0 -120px; + text-align:left +} + +ul#category-tabs li.ui-tabs-selected,#poststuff .togbox +{ + -khtml-border-bottom-left-radius:0; + -khtml-border-bottom-right-radius:3px; + -khtml-border-top-left-radius:0; + -khtml-border-top-right-radius:3px; + -moz-border-radius-bottomleft:0; + -moz-border-radius-bottomright:3px; + -moz-border-radius-topleft:0; + -moz-border-radius-topright:3px; + -webkit-border-bottom-left-radius:0; + -webkit-border-bottom-right-radius:3px; + -webkit-border-top-left-radius:0; + -webkit-border-top-right-radius:3px; + border-bottom-left-radius:0; + border-bottom-right-radius:3px; + border-top-left-radius:0; + border-top-right-radius:3px +} + +div.ui-tabs-panel +{ + margin:0 120px 0 0 +} + +#tagchecklist span +{ + float:right; + margin-left:25px; + margin-right:0 +} + +#tagchecklist span a { + margin: 6px -9px 0 0; float: right; - font: 700 16px/130% "Times New Roman", Times, serif; - } -#adminmenu a.current { - border-right: 0; - border-left: 2px solid #4f96c8; - } -#submenu, #minisub { - padding: 1px 3em 0 2em; - } -#submenu { - height: 28px; - } -#submenu a { - margin: 0 0 0 10px; - display: block; - float: right; - line-height: 155%; - } -#submenu .current { - border-right: 0; - border-left: 2px solid #045290; - } -.dbx-content input, .dbx-content select { - margin-right: 8px; - } -#newcat { - width: 100px; - } -.updated, .confirm { - background-position: 98.5%; - padding: 0 3em 0 1em; - } -.page-numbers { - margin-right: auto; - margin-left: 3px; - } -.wrap ul { - margin-right: 45%; - margin-left: 0; - } -* html .wrap ul { - margin-right: 50%; - } +} + + +.tablenav .tablenav-pages +{ + float:left !important; + width:200px +} + +.tablenav-pages .page-numbers +{ + display:block; + float:right +} + +.side-info ul +{ + padding-left:0; + padding-right:18px +} + +.form-table table.color-palette { + float:right; +} + +#pass-strength-result +{ + float:right; + margin-right:0; + margin-left:5px; +} + +td.comment p.comment-author img.avatar +{ + float:right !important; + margin-right:0 !important; + margin-left:8px !important; +} + +#footer +{ + padding:10px 0 0 +} + +#footer p +{ + height:35px; + margin-right:20px; + padding:12px 40px 0 0; +} + +#submenu,#wpbody +{ + clear:both; +} + +#submenu li,ul.subsubsub li a +{ + padding:0; +} + +table.widefat th,.form-table th +{ + text-align:right +} + +.widefat th input { + margin: 0 8px 0 0; + padding: 0; +} + +.available-theme,#tagchecklist span a +{ + float:right +} +#template div { + margin-right:0; + margin-left:190px; +} +.submitbox .submit { + text-align:right; +} + +#editorcontainer { + border:1px solid; +} + .wrap h2 { - font-family: "Times New Roman", Times, serif; - } -#zeitgeist { - margin-right: 1em; - } -#zeitgeist ul { - margin: 0 .6em .3em 0; - padding: 0 .6em 0 0; - } -#categorydiv ul { - margin-left: auto; - margin-right: 10px; - } -a.view-link { - left: 6%; - right: auto; - margin-right: auto; - } -#postdiv #quicktags { - padding-right: 0; - padding-left: 6px; - margin-right: 0; - } -.options ul { - margin-right: 0; - } -*form#template > div > textarea#newcontent { - margin-right: -300px; - width: 107%; - } + margin: 5px -4px 0 0; + padding-right: 0px; + padding-left: 280px; +} + +div#message { + clear: both; +} diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php index 99af3b4..796ca07 100644 --- a/wp-admin/setup-config.php +++ b/wp-admin/setup-config.php @@ -1,6 +1,9 @@ <?php die(); define('WP_INSTALLING', true); +//These two defines are required to allow us to use require_wp_db() to load the database class while being wp-content/wp-db.php aware +define('ABSPATH', dirname(dirname(__FILE__)).'/'); +define('WPINC', 'wp-includes'); require_once('../wp-includes/compat.php'); require_once('../wp-includes/functions.php'); @@ -11,7 +14,7 @@ if (!file_exists('../wp-config-sample.php')) $configFile = file('../wp-config-sample.php'); -if ( !is_writable('../')) +if ( !is_writable('../')) wp_die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually."); // Check if wp-config.php has been created @@ -29,60 +32,10 @@ function display_header(){ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> -<title>WordPress › Setup Configuration File</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<style media="screen" type="text/css"> - <!-- - html { - background: #eee; - } - body { - background: #fff; - color: #000; - font-family: Georgia, "Times New Roman", Times, serif; - margin-left: 20%; - margin-right: 20%; - padding: .2em 2em; - } - - h1 { - color: #006; - font-size: 18px; - font-weight: lighter; - } - - h2 { - font-size: 16px; - } - - p, li, dt { - line-height: 140%; - padding-bottom: 2px; - } +<title>WordPress › Setup Configuration File</title> +<link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install.css" type="text/css" /> - ul, ol { - padding: 5px 5px 5px 20px; - } - #logo { - margin-bottom: 2em; - } - .step a, .step input { - font-size: 2em; - } - td input { - font-size: 1.5em; - } - .step, th { - text-align: right; - } - #footer { - text-align: center; - border-top: 1px solid #ccc; - padding-top: 1em; - font-style: italic; - } - --> - </style> </head> <body> <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1> @@ -103,17 +56,18 @@ switch($step) { <li>Table prefix (if you want to run more than one WordPress in a single database) </li> </ol> <p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p> -<p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready, <a href="setup-config.php?step=1">let’s go</a>! </p> +<p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…</p> + +<p><a href="setup-config.php?step=1" class="button">Let’s go!</a></p> <?php break; case 1: display_header(); ?> -</p> <form method="post" action="setup-config.php?step=2"> <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p> - <table> + <table class="form-table"> <tr> <th scope="row">Database Name</th> <td><input name="dbname" type="text" size="25" value="wordpress" /></td> @@ -141,7 +95,7 @@ switch($step) { </tr> </table> <h2 class="step"> - <input name="submit" type="submit" value="Submit" /> + <input name="submit" type="submit" value="Submit" class="button" /> </h2> </form> <?php @@ -162,7 +116,7 @@ switch($step) { define('DB_HOST', $dbhost); // We'll fail here if the values are no good. - require_once('../wp-includes/wp-db.php'); + require_wp_db(); if ( !empty($wpdb->error) ) wp_die($wpdb->error->get_error_message()); @@ -191,14 +145,15 @@ switch($step) { } fclose($handle); chmod('../wp-config.php', 0666); - + display_header(); ?> -<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p> +<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…</p> + +<p><a href="install.php" class="button">Run the install</a></p> <?php break; } ?> -<p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p> </body> </html> diff --git a/wp-admin/sidebar.php b/wp-admin/sidebar.php index 830a7e2..9287285 100644 --- a/wp-admin/sidebar.php +++ b/wp-admin/sidebar.php @@ -11,13 +11,16 @@ if ('b' == $_GET['a']) { ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> -<title>WordPress › Posted</title> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=UTF-8" /> -<?php wp_admin_css(); ?> +<title><?php _e('WordPress › Posted'); ?></title> +<?php +wp_admin_css( 'css/global' ); +wp_admin_css(); +?> </head> <body> - <p>Posted !</p> - <p><a href="sidebar.php">Click here</a> to post again.</p> + <p><?php _e('Posted !'); ?></p> + <p><?php printf(__('<a href="%s">Click here</a> to post again.'), 'sidebar.php'); ?></p> </body> </html><?php @@ -26,9 +29,12 @@ if ('b' == $_GET['a']) { ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> -<title>WordPress › Sidebar</title> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('blog_charset'); ?>" /> -<?php wp_admin_css(); ?> +<title><?php _e('WordPress › Sidebar'); ?></title> +<?php +wp_admin_css( 'css/global' ); +wp_admin_css(); +?> <style type="text/css" media="screen"> form { padding: 3px; @@ -49,13 +55,15 @@ form { <body id="sidebar"> <h1 id="wphead"><a href="http://wordpress.org/" rel="external">WordPress</a></h1> <form name="post" action="post.php" method="post"> -<div><input type="hidden" name="action" value="post" /> +<div> +<input type="hidden" name="action" value="post" /> <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> <input type="hidden" name="mode" value="sidebar" /> -<p>Title: +<?php wp_nonce_field('add-post'); ?> +<p><?php _e('Title:'); ?> <input type="text" name="post_title" size="20" tabindex="1" style="width: 100%;" /> </p> -<p>Categories: +<p><?php _e('Categories:'); ?> <span class="sidebar-categories"> <?php dropdown_categories(); ?> </span> @@ -65,9 +73,9 @@ Post: <textarea rows="8" cols="12" style="width: 100%" name="content" tabindex="2"></textarea> </p> <p> - <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="Save as Draft" /> + <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft'); ?>" /> <?php if ( current_user_can('publish_posts') ) : ?> - <input name="publish" type="submit" id="publish" tabindex="6" style="font-weight: bold;" value="Publish" /> + <input name="publish" type="submit" id="publish" tabindex="6" value="<?php _e('Publish') ?>" class="button button-highlighted" /> <?php endif; ?> </p> </div> diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 37f4dd9..3b4103b 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -28,26 +28,8 @@ if ( isset($_GET['action']) ) { check_admin_referer('switch-theme_' . $_GET['template']); if ('activate' == $_GET['action']) { - $found = false; - while( list( $key, $details ) = each( $themes ) ) { - if( $details[ 'Template' ] == $_GET['template'] && $details[ 'Stylesheet' ] == $_GET['stylesheet'] ) { - $found = true; - break; - } - } - if( $found == true ) { - if ( isset($_GET['template']) ) - update_option('template', $_GET['template']); - - if ( isset($_GET['stylesheet']) ) - update_option('stylesheet', $_GET['stylesheet']); - - do_action('switch_theme', get_current_theme()); - - wp_redirect('themes.php?activated=true'); - } else { - wp_redirect('themes.php'); - } + switch_theme($_GET['template'], $_GET['stylesheet']); + wp_redirect('themes.php?activated=true'); exit; } } @@ -63,7 +45,7 @@ if( is_site_admin() ) { <?php if ( ! validate_current_theme() ) : ?> <div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> <?php elseif ( isset($_GET['activated']) ) : ?> -<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site »</a>'), get_bloginfo('url') . '/'); ?></p></div> +<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">Visit site</a>'), get_bloginfo('url') . '/'); ?></p></div> <?php endif; ?> @@ -75,9 +57,11 @@ if( is_site_admin() ) { <?php endif; ?> <h3><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h3> <p><?php echo $ct->description; ?></p> +<?php if ( $ct->tags ) : ?> +<p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p> +<?php endif; ?> </div> -<br style="clear: both" /> <h2><?php _e('Available Themes'); ?></h2> <?php if ( 1 < count($themes) ) { ?> @@ -98,6 +82,7 @@ foreach ($theme_names as $theme_name) { $author = $themes[$theme_name]['Author']; $screenshot = $themes[$theme_name]['Screenshot']; $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; + $tags = $themes[$theme_name]['Tags']; $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template); ?> <div class="available-theme"> @@ -110,6 +95,9 @@ foreach ($theme_names as $theme_name) { </a> <p><?php echo $description; ?></p> +<?php if ( $tags ) : ?> +<p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p> +<?php endif; ?> </div> <?php } // end foreach theme_names ?> diff --git a/wp-admin/update.php b/wp-admin/update.php index b047384..34e9380 100644 --- a/wp-admin/update.php +++ b/wp-admin/update.php @@ -6,15 +6,25 @@ if ( !current_user_can('edit_plugins') ) wp_die('<p>'.__('You do not have sufficient permissions to update plugins for this blog.').'</p>'); function request_filesystem_credentials($form_post, $type = '', $error = false) { + $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error); + if ( '' !== $req_cred ) + return $req_cred; + if ( empty($type) ) $type = get_filesystem_method(); if ( 'direct' == $type ) - return array(); + return true; + + if( ! $credentials = get_option('ftp_credentials') ) + $credentials = array(); + // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) + $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); + $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); + $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); + $credentials['ssl'] = defined('FTP_SSL') ? FTP_SSL : (!empty($_POST['ssl']) ? $_POST['ssl'] : $credentials['ssl']); - if ( ! $error && !empty($_POST['password']) && !empty($_POST['username']) && !empty($_POST['hostname']) ) { - $credentials = array('hostname' => $_POST['hostname'], 'username' => $_POST['username'], - 'password' => $_POST['password'], 'ssl' => $_POST['ssl']); + if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { $stored_credentials = $credentials; unset($stored_credentials['password']); update_option('ftp_credentials', $stored_credentials); @@ -24,11 +34,10 @@ function request_filesystem_credentials($form_post, $type = '', $error = false) $username = ''; $password = ''; $ssl = ''; - if ( $credentials = get_option('ftp_credentials') ) + if ( !empty($credentials) ) extract($credentials, EXTR_OVERWRITE); - if( $error ){ + if( $error ) echo '<div id="message" class="error"><p>' . __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.') . '</p></div>'; - } ?> <form action="<?php echo $form_post ?>" method="post"> <div class="wrap"> @@ -37,20 +46,20 @@ function request_filesystem_credentials($form_post, $type = '', $error = false) <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Hostname:') ?></th> -<td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>" size="40" /></td> +<td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Username:') ?></th> -<td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>" size="40" /></td> +<td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Password:') ?></th> -<td><input name="password" type="password" id="password" value="<?php echo attribute_escape($password) ?>" size="40" /></td> +<td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Use SSL:') ?></th> <td> -<select name="ssl" id="ssl"> +<select name="ssl" id="ssl"<?php if( defined('FTP_SSL') ) echo ' disabled="disabled"' ?>> <?php foreach ( array(0 => __('No'), 1 => __('Yes')) as $key => $value ) : $selected = ($ssl == $value) ? 'selected="selected"' : ''; @@ -77,7 +86,7 @@ function show_message($message) { else $message = $message->get_error_message(); } - echo "<p>$message</p>"; + echo "<p>$message</p>\n"; } function do_plugin_upgrade($plugin) { @@ -86,12 +95,12 @@ function do_plugin_upgrade($plugin) { $url = wp_nonce_url("update.php?action=upgrade-plugin&plugin=$plugin", "upgrade-plugin_$plugin"); if ( false === ($credentials = request_filesystem_credentials($url)) ) return; - - if( ! WP_Filesystem($credentials) ){ + + if ( ! WP_Filesystem($credentials) ) { request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again return; } - + echo '<div class="wrap">'; echo '<h2>' . __('Upgrade Plugin') . '</h2>'; if ( $wp_filesystem->errors->get_error_code() ) { @@ -101,18 +110,25 @@ function do_plugin_upgrade($plugin) { return; } + $was_activated = is_plugin_active($plugin); //Check now, It'll be deactivated by the next line if it is, + $result = wp_update_plugin($plugin, 'show_message'); - if ( is_wp_error($result) ) + if ( is_wp_error($result) ) { show_message($result); - else - echo __('Plugin upgraded successfully'); + } else { + //Result is the new plugin file relative to PLUGINDIR + show_message(__('Plugin upgraded successfully')); + if( $result && $was_activated ){ + show_message(__('Attempting reactivation of the plugin')); + echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>'; + } + } echo '</div>'; } if ( isset($_GET['action']) ) { - if ( isset($_GET['plugin']) ) - $plugin = trim($_GET['plugin']); + $plugin = isset($_GET['plugin']) ? trim($_GET['plugin']) : ''; if ( 'upgrade-plugin' == $_GET['action'] ) { check_admin_referer('upgrade-plugin_' . $plugin); @@ -121,6 +137,36 @@ if ( isset($_GET['action']) ) { require_once('admin-header.php'); do_plugin_upgrade($plugin); include('admin-footer.php'); + } elseif ('activate-plugin' == $_GET['action'] ) { + check_admin_referer('activate-plugin_' . $plugin); + if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { + wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); + activate_plugin($plugin); + wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); + die(); + } + ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> +<head> +<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> +<title><?php bloginfo('name') ?> › <?php _e('Plugin Reactivation'); ?> — <?php _e('WordPress'); ?></title> +<?php +wp_admin_css( 'css/global' ); +wp_admin_css( 'css/colors' ); +?> +</head> +<body> +<?php + if( isset($_GET['success']) ) + echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; + + if( isset($_GET['failure']) ){ + echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; + error_reporting( E_ALL ^ E_NOTICE ); + @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. + include(ABSPATH . PLUGINDIR . '/' . $plugin); + } + echo "</body></html>"; } } diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 12dfb11..86b0b75 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -1,4 +1,5 @@ <?php // Deprecated. Use includes/upgrade.php. +_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/upgrade.php' ); require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); ?> diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php index b8069b5..d7274d1 100644 --- a/wp-admin/upgrade.php +++ b/wp-admin/upgrade.php @@ -1,7 +1,7 @@ <?php define('WP_INSTALLING', true); if (!file_exists('../wp-config.php')) - die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file."); + die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='setup-config.php' class='button'>Create a Configuration File</a>"); require('../wp-config.php'); timer_start(); @@ -27,17 +27,19 @@ else <h2><?php _e('No Upgrade Required'); ?></h2> <p><?php _e('Your WordPress database is already up-to-date!'); ?></p> -<h2 class="step"><a href="<?php echo get_option('home'); ?>/"><?php _e('Continue »'); ?></a></h2> +<h2 class="step"><a href="<?php echo get_option('home'); ?>/"><?php _e('Continue'); ?></a></h2> <?php else : switch($step) : case 0: - $goback = clean_url(stripslashes(wp_get_referer())); + $goback = stripslashes(wp_get_referer()); + $goback = clean_url($goback, null, 'url'); + $goback = urlencode($goback); ?> <h2><?php _e('Database Upgrade Required'); ?></h2> <p><?php _e('Your WordPress database is out-of-date, and must be upgraded before you can continue.'); ?></p> <p><?php _e('The upgrade process may take a while, so please be patient.'); ?></p> -<h2 class="step"><a href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress »'); ?></a></h2> +<h2 class="step"><a href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress'); ?></a></h2> <?php break; case 1: @@ -45,8 +47,10 @@ switch($step) : if ( empty( $_GET['backto'] ) ) $backto = __get_option('home') . '/'; - else - $backto = clean_url(stripslashes($_GET['backto'])); + else { + $backto = stripslashes(urldecode($_GET['backto'])); + $backto = clean_url($backto, null, 'url'); + } if( $wpdb->get_row( "SELECT blog_id FROM wp_blog_versions WHERE blog_id = '{$wpdb->blogid}'" ) ) { $wpdb->query( "UPDATE wp_blog_versions SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); } else { @@ -55,7 +59,7 @@ switch($step) : ?> <h2><?php _e('Upgrade Complete'); ?></h2> <p><?php _e('Your WordPress database has been successfully upgraded!'); ?></p> - <h2 class="step"><a href="<?php echo $backto; ?>"><?php _e('Continue »'); ?></a></h2> + <h2 class="step"><a href="<?php echo $backto; ?>"><?php _e('Continue'); ?></a></h2> <!-- <pre> diff --git a/wp-admin/upload.php b/wp-admin/upload.php index bfbd9fc..0f7412d 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -1,135 +1,249 @@ <?php require_once('admin.php'); -@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); - if (!current_user_can('upload_files')) wp_die(__('You do not have permission to upload files.')); -wp_reset_vars(array('action', 'tab', 'from_tab', 'style', 'post_id', 'ID', 'paged', 'post_title', 'post_content', 'delete')); - -// IDs should be integers -$ID = (int) $ID; -$post_id = (int) $post_id; - -// Require an ID for the edit screen -if ( $action == 'edit' && !$ID ) - wp_die(__("You are not allowed to be here")); - -require_once('includes/upload.php'); -if ( !$tab ) - $tab = 'browse-all'; - -do_action( "upload_files_$tab" ); - -$pid = 0; -if ( $post_id < 0 ) - $pid = $post_id; -elseif ( get_post( $post_id ) ) - $pid = $post_id; -$wp_upload_tabs = array(); -$all_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'"); -$post_atts = 0; - -if ( $pid ) { - // 0 => tab display name, 1 => required cap, 2 => function that produces tab content, 3 => total number objects OR array(total, objects per page), 4 => add_query_args - $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload', 0); - if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") ) - $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse", $action ? 0 : $post_atts); - if ( $post_atts < $all_atts ) - $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts); -} else - $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts); - - $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() )); - -if ( !is_callable($wp_upload_tabs[$tab][2]) ) { - $to_tab = isset($wp_upload_tabs['upload']) ? 'upload' : 'browse-all'; - wp_redirect( add_query_arg( 'tab', $to_tab ) ); +// Handle bulk deletes +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { + check_admin_referer('bulk-media'); + foreach( (array) $_GET['delete'] as $post_id_del ) { + $post_del = & get_post($post_id_del); + + if ( !current_user_can('delete_post', $post_id_del) ) + wp_die( __('You are not allowed to delete this post.') ); + + if ( $post_del->post_type == 'attachment' ) + if ( ! wp_delete_attachment($post_id_del) ) + wp_die( __('Error in deleting...') ); + } + + $location = 'upload.php'; + if ( $referer = wp_get_referer() ) { + if ( false !== strpos($referer, 'upload.php') ) + $location = $referer; + } + + $location = add_query_arg('message', 2, $location); + $location = remove_query_arg('posted', $location); + wp_redirect($location); + exit; +} elseif ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); exit; } -foreach ( $wp_upload_tabs as $t => $tab_array ) { - if ( !current_user_can( $tab_array[1] ) ) { - unset($wp_upload_tabs[$t]); - if ( $tab == $t ) - wp_die(__("You are not allowed to be here")); +$title = __('Media Library'); +$parent_file = 'edit.php'; +wp_enqueue_script( 'admin-forms' ); + +list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); + +if ( is_singular() ) + wp_enqueue_script( 'admin-comments' ); + +require_once('admin-header.php'); + +if ( !isset( $_GET['paged'] ) ) + $_GET['paged'] = 1; + +?> + +<div class="wrap"> + +<form id="posts-filter" action="" method="get"> +<h2><?php +if ( is_singular() ) { + printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title)); +} else { + $post_mime_type_label = _c('Manage Media|manage media header'); + if ( isset($_GET['post_mime_type']) && in_array( $_GET['post_mime_type'], array_keys($post_mime_types) ) ) + $post_mime_type_label = $post_mime_types[$_GET['post_mime_type']][1]; + if ( $post_listing_pageable && !is_archive() && !is_search() ) + $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_mime_type_label) : sprintf(__('Latest %s'), $post_mime_type_label); + else + $h2_noun = $post_mime_type_label; + // Use $_GET instead of is_ since they can override each other + $h2_author = ''; + $_GET['author'] = (int) $_GET['author']; + if ( $_GET['author'] != 0 ) { + if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion + $h2_author = ' ' . __('by other authors'); + } else { + $author_user = get_userdata( get_query_var( 'author' ) ); + $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); + } } + $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : ''; + $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; + $h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : ''; + $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; + printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month ); } +?></h2> -if ( 'inline' == $style ) : ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> -<head> -<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> -<title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — WordPress</title> -<?php wp_admin_css(); ?> -<script type="text/javascript"> -//<![CDATA[ -function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} -//]]> -</script> -<?php do_action('admin_print_scripts'); wp_upload_admin_head(); ?> -</head> -<body> +<ul class="subsubsub"> <?php -else : - add_action( 'admin_head', 'wp_upload_admin_head' ); - include_once('admin-header.php'); +$type_links = array(); +$_num_posts = (array) wp_count_attachments(); +$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); +foreach ( $matches as $type => $reals ) + foreach ( $reals as $real ) + $num_posts[$type] += $_num_posts[$real]; +$class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; +$type_links[] = "<li><a href=\"upload.php\"$class>".__('All Types')."</a>"; +foreach ( $post_mime_types as $mime_type => $label ) { + $class = ''; + + if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) + continue; + + if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) + $class = ' class="current"'; + + $type_links[] = "<li><a href=\"upload.php?post_mime_type=$mime_type\"$class>" . + sprintf(__ngettext($label[2][0], $label[2][1], $num_posts[$mime_type]), number_format_i18n( $num_posts[$mime_type] )) . '</a>'; +} +echo implode(' | </li>', $type_links) . '</li>'; +unset($type_links); ?> - <div class='wrap'> - <h2><?php _e('Uploads'); ?></h2> +</ul> + <?php +if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> +<div id="message" class="updated fade"><p><strong><?php _e('Your media has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View media'); ?></a> | <a href="media.php?action=edit&attachment_id=<?php echo $_GET['posted']; ?>"><?php _e('Edit media'); ?></a></p></div> +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); endif; -echo "<ul id='upload-menu'>\n"; -foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check - $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') ); - if ( isset($tab_array[4]) && is_array($tab_array[4]) ) - $href = add_query_arg( $tab_array[4], $href ); - $_href = clean_url( $href); - $page_links = ''; - $class = 'upload-tab alignleft'; - if ( $tab == $t ) { - $class .= ' current'; - if ( $tab_array[3] ) { - if ( is_array($tab_array[3]) ) { - $total = $tab_array[3][0]; - $per = $tab_array[3][1]; - } else { - $total = $tab_array[3]; - $per = 10; - } - $page_links = paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'total' => ceil($total / $per), - 'current' => $paged ? $paged : 1, - 'prev_text' => '«', - 'next_text' => '»' - )); - if ( $page_links ) - $page_links = "<span id='current-tab-nav'>: $page_links</span>"; - } - } +$messages[1] = __('Media updated.'); +$messages[2] = __('Media deleted.'); + +if (isset($_GET['message'])) : ?> +<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); +endif; +?> + +<p id="post-search"> + <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" /> + <input type="submit" value="<?php _e( 'Search Media' ); ?>" class="button" /> +</p> + +<?php do_action('restrict_manage_posts'); ?> + +<div class="tablenav"> + +<?php +$page_links = paginate_links( array( + 'base' => add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'total' => $wp_query->max_num_pages, + 'current' => $_GET['paged'] +)); + +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; +?> + +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<?php wp_nonce_field('bulk-media'); ?> +<?php + +if ( !is_singular() ) : + $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; - echo "\t<li class='$class'><a href='$_href' class='upload-tab-link' title='{$tab_array[0]}'>{$tab_array[0]}</a>$page_links</li>\n"; + $arc_result = $wpdb->get_results( $arc_query ); + + $month_count = count($arc_result); + + if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?> +<select name='m'> +<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> +<?php +foreach ($arc_result as $arc_row) { + if ( $arc_row->yyear == 0 ) + continue; + $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); + + if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) + $default = ' selected="selected"'; + else + $default = ''; + + echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>"; + echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; + echo "</option>\n"; } -unset($t, $tab_array, $href, $_href, $page_links, $total, $per, $class); -echo "</ul>\n\n"; +?> +</select> +<?php endif; // month_count ?> + +<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" /> + +<?php endif; // is_singular ?> + +</div> + +<br class="clear" /> +</div> + +<br class="clear" /> + +<?php include( 'edit-attachment-rows.php' ); ?> -echo "<div id='upload-content' class='$tab'>\n"; +</form> -call_user_func( $wp_upload_tabs[$tab][2] ); +<div id="ajax-response"></div> -echo "</div>\n"; +<div class="tablenav"> + +<?php +if ( $page_links ) + echo "<div class='tablenav-pages'>$page_links</div>"; +?> + +</div> + +<br class="clear" /> + +<?php + +if ( 1 == count($posts) && is_singular() ) : + + $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); + if ( $comments ) : + // Make sure comments, post, and post_author are cached + update_comment_cache($comments); + $post = get_post($id); + $authordata = get_userdata($post->post_author); + ?> + +<br class="clear" /> + +<table class="widefat" style="margin-top: .5em"> +<thead> + <tr> + <th scope="col"><?php _e('Comment') ?></th> + <th scope="col"><?php _e('Date') ?></th> + <th scope="col"><?php _e('Actions') ?></th> + </tr> +</thead> +<tbody id="the-comment-list" class="list:comment"> +<?php + foreach ($comments as $comment) + _wp_comment_row( $comment->comment_ID, 'detail', false, false ); +?> +</tbody> +</table> + +<?php + +endif; // comments +endif; // posts; + +?> -if ( 'inline' != $style ) : - echo "<div class='clear'></div></div>"; - include_once('admin-footer.php'); -else : ?> -<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> +</div> -</body> -</html> -<?php endif; ?> +<?php include('admin-footer.php'); ?> diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index ec5d3f6..3327c2d 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -1,12 +1,71 @@ <?php + require_once('admin.php'); -$title = __('Edit User'); -if ( current_user_can('edit_users') ) - $parent_file = 'users.php'; +if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE ) + $is_profile_page = true; +else + $is_profile_page = false; + +function profile_js ( ) { +?> +<script type="text/javascript"> + function check_pass_strength ( ) { + + var pass = jQuery('#pass1').val(); + var user = jQuery('#user_login').val(); + + // get the result as an object, i'm tired of typing it + var res = jQuery('#pass-strength-result'); + + var strength = passwordStrength(pass, user); + + jQuery(res).removeClass('short bad good strong'); + + if ( strength == pwsL10n.bad ) { + jQuery(res).addClass('bad'); + jQuery(res).html( pwsL10n.bad ); + } + else if ( strength == pwsL10n.good ) { + jQuery(res).addClass('good'); + jQuery(res).html( pwsL10n.good ); + } + else if ( strength == pwsL10n.strong ) { + jQuery(res).addClass('strong'); + jQuery(res).html( pwsL10n.strong ); + } + else { + // this catches 'Too short' and the off chance anything else comes along + jQuery(res).addClass('short'); + jQuery(res).html( pwsL10n.short ); + } + + } + + jQuery(function($) { + $('#pass1').keyup( check_pass_strength ) + $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')}); + } ); + + jQuery(document).ready( function() { + jQuery('#pass1,#pass2').attr('autocomplete','off'); + }); +</script> +<?php +} + +if ( $is_profile_page ) { + add_action('admin_head', 'profile_js'); + wp_enqueue_script('jquery'); + wp_enqueue_script('password-strength-meter'); +} + +$title = $is_profile_page? __('Profile') : __('Edit User'); +if ( current_user_can('edit_users') && !$is_profile_page ) + $submenu_file = 'users.php'; else - $parent_file = 'profile.php'; -$submenu_file = 'users.php'; + $submenu_file = 'profile.php'; +$parent_file = 'users.php'; wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer')); @@ -18,7 +77,12 @@ if ( !is_site_admin() && ($user_id != $current_user->ID) ) $user_id = (int) $user_id; if ( !$user_id ) - wp_die(__('Invalid user ID.')); + if ( $is_profile_page ) { + $current_user = wp_get_current_user(); + $user_id = $current_user->ID; + } else { + wp_die(__('Invalid user ID.')); + } switch ($action) { case 'switchposts': @@ -36,13 +100,17 @@ check_admin_referer('update-user_' . $user_id); if ( !current_user_can('edit_user', $user_id) ) wp_die(__('You do not have permission to edit this user.')); +if ( $is_profile_page ) { + do_action('personal_options_update'); +} + $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$user_id}' AND meta_key = '{$wpdb->base_prefix}{$wpdb->blogid}_capabilities' AND meta_value = 'a:0:{}'" ); $errors = edit_user($user_id); if( $cap == null ) $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id = '{$user_id}' AND meta_key = '{$wpdb->base_prefix}{$wpdb->blogid}_capabilities' AND meta_value = 'a:0:{}'" ); if( !is_wp_error( $errors ) ) { - $redirect = "user-edit.php?user_id=$user_id&updated=true"; + $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true"; $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); wp_redirect($redirect); exit; @@ -60,7 +128,7 @@ include ('admin-header.php'); <?php if ( isset($_GET['updated']) ) : ?> <div id="message" class="updated fade"> <p><strong><?php _e('User updated.') ?></strong></p> - <?php if ( $wp_http_referer ) : ?> + <?php if ( $wp_http_referer && !$is_profile_page ) : ?> <p><a href="users.php"><?php _e('« Back to Authors and Users'); ?></a></p> <?php endif; ?> </div> @@ -76,10 +144,10 @@ include ('admin-header.php'); </div> <?php } else { ?> -<div class="wrap"> -<h2><?php _e('Edit User'); ?></h2> +<div class="wrap" id="profile-page"> +<h2><?php $is_profile_page? _e('Your Profile and Personal Options') : _e('Edit User'); ?></h2> -<form name="profile" id="your-profile" action="user-edit.php" method="post"> +<form name="profile" id="your-profile" action="" method="post"> <?php wp_nonce_field('update-user_' . $user_id) ?> <?php if ( $wp_http_referer ) : ?> <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" /> @@ -89,23 +157,63 @@ include ('admin-header.php'); <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> </p> -<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></p> +<h3><?php _e('Personal Options'); ?></h3> -<p class="submit"><input type="submit" value="<?php _e('Update User »'); ?>" name="submit" /></p> +<table class="form-table"> +<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?> + <tr> + <th scope="row"><?php _e('Visual Editor')?></th> + <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></td> + </tr> +<?php endif; ?> +<tr> +<th scope="row"><?php _e('Admin Color Scheme')?></th> +<td> +<?php +$current_color = get_user_option('admin_color'); +if ( empty($current_color) ) + $current_color = 'fresh'; +foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> +<div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, $current_color); ?> /> + <table class="color-palette"> + <tr> + <?php + foreach ( $color_info->colors as $html_color ): ?> + <td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td> + <?php endforeach; ?> + </tr> + </table> + + <label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label> +</div> +<?php endforeach; ?> +</td> +</tr> +</table> -<fieldset> -<legend><?php _e('Name'); ?></legend> -<p><label><?php _e('Username: (no editing)'); ?><br /> -<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" /> -</label></p> +<?php + if ( $is_profile_page ) { + do_action('profile_personal_options'); + } +?> -<p><label><?php _e('Role:') ?><br /> +<h3><?php _e('Name') ?></h3> + +<table class="form-table"> + <tr> + <th><label for="user_login"><?php _e('Username'); ?></label></th> + <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" /> <?php _e('Your username cannot be changed'); ?></td> + </tr> + +<?php if ( !$is_profile_page ): ?> +<tr><th><label for="role"><?php _e('Role:') ?></label></th> <?php // print_r($profileuser); -echo '<select name="role">'; +echo '<td><select name="role" id="role">'; $role_list = ''; $user_has_role = false; foreach($wp_roles->role_names as $role => $name) { + $name = translate_with_context($name); if ( $profileuser->has_cap($role) ) { $selected = ' selected="selected"'; $user_has_role = true; @@ -118,88 +226,114 @@ if ( $user_has_role ) $role_list .= '<option value="">' . __('— No role for this blog —') . '</option>'; else $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>'; -echo $role_list . '</select>'; -?></label></p> - -<p><label><?php _e('First name:') ?><br /> -<input type="text" name="first_name" value="<?php echo $profileuser->first_name ?>" /></label></p> - -<p><label><?php _e('Last name:') ?><br /> -<input type="text" name="last_name" value="<?php echo $profileuser->last_name ?>" /></label></p> - -<p><label><?php _e('Nickname:') ?><br /> -<input type="text" name="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p> - -<p><label><?php _e('Display name publicly as:') ?> <br /> -<select name="display_name"> -<option value="<?php echo $profileuser->display_name; ?>"><?php echo $profileuser->display_name; ?></option> -<option value="<?php echo $profileuser->nickname ?>"><?php echo $profileuser->nickname ?></option> -<option value="<?php echo $profileuser->user_login ?>"><?php echo $profileuser->user_login ?></option> -<?php if ( !empty( $profileuser->first_name ) ) : ?> -<option value="<?php echo $profileuser->first_name ?>"><?php echo $profileuser->first_name ?></option> -<?php endif; ?> -<?php if ( !empty( $profileuser->last_name ) ) : ?> -<option value="<?php echo $profileuser->last_name ?>"><?php echo $profileuser->last_name ?></option> -<?php endif; ?> -<?php if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) : ?> -<option value="<?php echo $profileuser->first_name." ".$profileuser->last_name ?>"><?php echo $profileuser->first_name." ".$profileuser->last_name ?></option> -<option value="<?php echo $profileuser->last_name." ".$profileuser->first_name ?>"><?php echo $profileuser->last_name." ".$profileuser->first_name ?></option> +echo $role_list . '</select></td></tr>'; +?> <?php endif; ?> -</select></label></p> -</fieldset> - -<fieldset> -<legend><?php _e('Contact Info'); ?></legend> -<p><label><?php _e('E-mail: (required)') ?><br /> -<input type="text" name="email" value="<?php echo $profileuser->user_email ?>" /></label></p> - -<p><label><?php _e('Website:') ?><br /> -<input type="text" name="url" value="<?php echo $profileuser->user_url ?>" /> -</label></p> - -<p><label><?php _e('AIM:') ?><br /> -<input type="text" name="aim" value="<?php echo $profileuser->aim ?>" /> -</label></p> - -<p><label><?php _e('Yahoo IM:') ?><br /> -<input type="text" name="yim" value="<?php echo $profileuser->yim ?>" /> -</label></p> - -<p><label><?php _e('Jabber / Google Talk:') ?><br /> -<input type="text" name="jabber" value="<?php echo $profileuser->jabber ?>" /></label> -</p> -</fieldset> -<br clear="all" /> -<fieldset> -<legend><?php _e('About the user'); ?></legend> -<p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p> -<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p> -</fieldset> +<tr> + <th><label for="first_name"><?php _e('First name') ?></label></th> + <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></td> +</tr> + +<tr> + <th><label for="last_name"><?php _e('Last name') ?></label></th> + <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" /></td> +</tr> + +<tr> + <th><label for="nickname"><?php _e('Nickname') ?></label></th> + <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></td> +</tr> + +<tr> + <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> + <td> + <select name="display_name" id="display_name"> + <?php + $public_display = array(); + $public_display[] = $profileuser->display_name; + $public_display[] = $profileuser->nickname; + $public_display[] = $profileuser->user_login; + $public_display[] = $profileuser->first_name; + $public_display[] = $profileuser->first_name.' '.$profileuser->last_name; + $public_display[] = $profileuser->last_name.' '.$profileuser->first_name; + $public_display = array_unique(array_filter(array_map('trim', $public_display))); + foreach($public_display as $item) { + ?> + <option value="<?php echo $item; ?>"><?php echo $item; ?></option> + <?php + } + ?> + </select> + </td> +</tr> +</table> + +<h3><?php _e('Contact Info') ?></h3> + +<table class="form-table"> +<tr> + <th><label for="email"><?php _e('E-mail') ?></label></th> + <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /> <?php _e('Required'); ?></td> +</tr> + +<tr> + <th><label for="url"><?php _e('Website') ?></label></th> + <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" /></td> +</tr> + +<tr> + <th><label for="aim"><?php _e('AIM') ?></label></th> + <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" /></td> +</tr> + +<tr> + <th><label for="yim"><?php _e('Yahoo IM') ?></label></th> + <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" /></td> +</tr> + +<tr> + <th><label for="jabber"><?php _e('Jabber / Google Talk') ?></label></th> + <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></td> +</tr> +</table> + +<h3><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></h3> + +<table class="form-table"> +<tr> + <th><label for="description"><?php _e('Biographical Info'); ?></label></th> + <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br /><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></td> +</tr> <?php $show_password_fields = apply_filters('show_password_fields', true); if ( $show_password_fields ) : ?> -<fieldset> -<legend><?php _e("Update User's Password"); ?></legend> -<p class="desc"><?php _e("If you would like to change the user's password type a new one twice below. Otherwise leave this blank."); ?></p> -<p><label><?php _e('New Password:'); ?><br /> -<input type="password" name="pass1" size="16" value="" /> -</label></p> -<p><label><?php _e('Type it one more time:'); ?><br /> -<input type="password" name="pass2" size="16" value="" /> -</label></p> -</fieldset> +<tr> + <th><label for="pass1"><?php _e('New Password:'); ?></label></th> + <td><input type="password" name="pass1" id="pass1" size="16" value="" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br /> + <input type="password" name="pass2" id="pass2" size="16" value="" /> <?php _e("Type your new password again."); ?><br /> + <?php if ( $is_profile_page ): ?> + <p><strong><?php _e('Password Strength:'); ?></strong></p> + <div id="pass-strength-result"><?php _e('Too short'); ?></div> <?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.'); ?> + <?php endif; ?> + </td> +</tr> <?php endif; ?> +</table> -<?php do_action('edit_user_profile'); ?> +<?php + if ( $is_profile_page ) { + do_action('show_user_profile'); + } else { + do_action('edit_user_profile'); + } +?> -<br clear="all" /> - <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform"> - <?php - if(count($profileuser->caps) > count($profileuser->roles)): - ?> +<?php if (count($profileuser->caps) > count($profileuser->roles)): ?> +<br class="clear" /> + <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform"> <tr> <th scope="row"><?php _e('Additional Capabilities:') ?></th> <td><?php @@ -213,14 +347,13 @@ if ( $show_password_fields ) : echo $output; ?></td> </tr> - <?php - endif; - ?> </table> +<?php endif; ?> + <p class="submit"> <input type="hidden" name="action" value="update" /> <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" /> - <input type="submit" value="<?php _e('Update User »') ?>" name="submit" /> + <input type="submit" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" /> </p> </form> </div> diff --git a/wp-admin/users.php b/wp-admin/users.php index 7080419..f7a9e76 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -11,117 +11,28 @@ $parent_file = 'users.php'; $action = $_REQUEST['action']; $update = ''; -if ( empty($_POST) ) { +if ( empty($action) ) { + if ( isset($_GET['deleteit']) ) + $action = 'delete'; + elseif ( isset($_GET['changeit']) && !empty($_GET['new_role']) ) + $action = 'promote'; +} + +if ( empty($_REQUEST) ) { $referer = '<input type="hidden" name="wp_http_referer" value="'. attribute_escape(stripslashes($_SERVER['REQUEST_URI'])) . '" />'; -} elseif ( isset($_POST['wp_http_referer']) ) { - $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_POST['wp_http_referer'])); +} elseif ( isset($_REQUEST['wp_http_referer']) ) { + $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_REQUEST['wp_http_referer'])); $referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />'; } else { $redirect = 'users.php'; } - -// WP_User_Search class -// by Mark Jaquith - - -class WP_User_Search { - var $results; - var $search_term; - var $page; - var $raw_page; - var $users_per_page = 50; - var $first_user; - var $last_user; - var $query_limit; - var $query_from_where; - var $total_users_for_query = 0; - var $too_many_total_users = false; - var $search_errors; - - function WP_User_Search ($search_term = '', $page = '') { // constructor - $this->search_term = $search_term; - $this->raw_page = ( '' == $page ) ? false : (int) $page; - $this->page = (int) ( '' == $page ) ? 1 : $page; - - $this->prepare_query(); - $this->query(); - $this->prepare_vars_for_template_usage(); - $this->do_paging(); - } - - function prepare_query() { - global $wpdb; - $this->first_user = ($this->page - 1) * $this->users_per_page; - $this->query_limit = 'LIMIT ' . $this->first_user . ',' . $this->users_per_page; - if ( $this->search_term ) { - $searches = array(); - $search_sql = 'AND ('; - foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) - $searches[] = $col . " LIKE '%$this->search_term%'"; - $search_sql .= implode(' OR ', $searches); - $search_sql .= ')'; - } - $this->query_from_where = "FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities' $search_sql"; - - } - - function query() { - global $wpdb; - $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_limit); - - if ( $this->results ) - $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit - else - $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); - } - - function prepare_vars_for_template_usage() { - $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone - } - - function do_paging() { - if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results - $this->paging_text = paginate_links( array( - 'total' => ceil($this->total_users_for_query / $this->users_per_page), - 'current' => $this->page, - 'prev_text' => __('« Previous Page'), - 'next_text' => __('Next Page »'), - 'base' => 'users.php?%_%', - 'format' => 'userspage=%#%', - 'add_args' => array( 'usersearch' => urlencode($this->search_term) ) - ) ); - } - } - - function get_results() { - return (array) $this->results; - } - - function page_links() { - echo $this->paging_text; - } - - function results_are_paged() { - if ( $this->paging_text ) - return true; - return false; - } - - function is_search() { - if ( $this->search_term ) - return true; - return false; - } -} - - switch ($action) { case 'promote': check_admin_referer('bulk-users'); - if (empty($_POST['users'])) { + if (empty($_REQUEST['users'])) { wp_redirect($redirect); exit(); } @@ -129,19 +40,19 @@ case 'promote': if ( !current_user_can('edit_users') ) wp_die(__('You can’t edit users.')); - $userids = $_POST['users']; + $userids = $_REQUEST['users']; $update = 'promote'; foreach($userids as $id) { if ( ! current_user_can('edit_user', $id) ) wp_die(__('You can’t edit that user.')); // The new role of the current user must also have edit_users caps - if($id == $current_user->ID && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { + if($id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users')) { $update = 'err_admin_role'; continue; } $user = new WP_User($id); - $user->set_role($_POST['new_role']); + $user->set_role($_REQUEST['new_role']); } wp_redirect(add_query_arg('update', $update, $redirect)); @@ -153,7 +64,7 @@ case 'dodelete': wp_die(__('This function is disabled.')); check_admin_referer('delete-users'); - if ( empty($_POST['users']) ) { + if ( empty($_REQUEST['users']) ) { wp_redirect($redirect); exit(); } @@ -161,7 +72,7 @@ case 'dodelete': if ( !current_user_can('delete_users') ) wp_die(__('You can’t delete users.')); - $userids = $_POST['users']; + $userids = $_REQUEST['users']; $update = 'del'; $delete_count = 0; @@ -173,12 +84,12 @@ case 'dodelete': $update = 'err_admin_del'; continue; } - switch($_POST['delete_option']) { + switch($_REQUEST['delete_option']) { case 'delete': wp_delete_user($id); break; case 'reassign': - wp_delete_user($id, $_POST['reassign_user']); + wp_delete_user($id, $_REQUEST['reassign_user']); break; } ++$delete_count; @@ -194,7 +105,7 @@ case 'delete': wp_die(__('This function is disabled.')); check_admin_referer('bulk-users'); - if ( empty($_POST['users']) ) { + if ( empty($_REQUEST['users']) ) { wp_redirect($redirect); exit(); } @@ -202,13 +113,14 @@ case 'delete': if ( !current_user_can('delete_users') ) $errors = new WP_Error('edit_users', __('You can’t delete users.')); - $userids = $_POST['users']; + $userids = $_REQUEST['users']; include ('admin-header.php'); ?> <form action="" method="post" name="updateusers" id="updateusers"> <?php wp_nonce_field('delete-users') ?> <?php echo $referer; ?> + <div class="wrap"> <h2><?php _e('Delete Users'); ?></h2> <p><?php _e('You have specified these users for deletion:'); ?></p> @@ -241,7 +153,7 @@ case 'delete': <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:')."</label> $user_dropdown"; ?></li> </ul> <input type="hidden" name="action" value="dodelete" /> - <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p> + <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" class="button-secondary" /></p> <?php else : ?> <p><?php _e('There are no valid users selected for deletion.'); ?></p> <?php endif; ?> @@ -333,7 +245,7 @@ case 'adduser': if ( is_wp_error( $user_id ) ) $add_user_errors = $user_id; else { - $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true)); + $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect ); wp_redirect( $redirect . '#user-' . $user_id ); die(); @@ -367,20 +279,19 @@ case 'addexistinguser': die(); break; default: + + if ( !empty($_GET['_wp_http_referer']) ) { + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); + exit; + } + wp_enqueue_script('admin-users'); + wp_enqueue_script('admin-forms'); include('admin-header.php'); // Query the users - $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); - - // Make the user objects - foreach ( $wp_user_search->get_results() as $userid ) { - $tmp_user = new WP_User($userid); - $roles = $tmp_user->roles; - $role = array_shift($roles); - $roleclasses[$role][$tmp_user->user_login] = $tmp_user; - } + $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'], $_GET['role']); if ( isset($_GET['update']) ) : switch($_GET['update']) { @@ -453,23 +364,74 @@ default: </div> <?php endif; ?> -<?php if ( $wp_user_search->too_many_total_users ) : ?> - <div id="message" class="updated"> - <p><?php echo $wp_user_search->too_many_total_users; ?></p> - </div> -<?php endif; ?> - <div class="wrap"> - +<form id="posts-filter" action="" method="get"> <?php if ( $wp_user_search->is_search() ) : ?> - <h2><?php printf(__('Users Matching "%s" by Role'), wp_specialchars($wp_user_search->search_term)); ?></h2> + <h2><?php printf(__('Users Matching "%s"'), wp_specialchars($wp_user_search->search_term)); ?></h2> <?php else : ?> - <h2><?php _e('User List by Role'); ?></h2> + <h2><?php _e('Manage Users'); ?></h2> <?php endif; ?> - <form action="" method="get" name="search" id="search"> - <p><input type="text" name="usersearch" id="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search Users »'); ?>" class="button" /></p> - </form> +<ul class="subsubsub"> +<?php +$role_links = array(); +$avail_roles = array(); +$users_of_blog = get_users_of_blog(); +//var_dump($users_of_blog); +foreach ( (array) $users_of_blog as $b_user ) { + $b_roles = unserialize($b_user->meta_value); + foreach ( (array) $b_roles as $b_role => $val ) { + if ( !isset($avail_roles[$b_role]) ) + $avail_roles[$b_role] = 0; + $avail_roles[$b_role]++; + } +} +unset($users_of_blog); + +$current_role = false; +$class = empty($_GET['role']) ? ' class="current"' : ''; +$role_links[] = "<li><a href=\"users.php\"$class>" . __('All Users') . "</a>"; +foreach ( $wp_roles->get_names() as $role => $name ) { + if ( !isset($avail_roles[$role]) ) + continue; + + $class = ''; + + if ( $role == $_GET['role'] ) { + $current_role = $_GET['role']; + $class = ' class="current"'; + } + + $name = translate_with_context($name); + $name = sprintf(_c('%1$s (%2$s)|user role with count'), $name, $avail_roles[$role]); + $role_links[] = "<li><a href=\"users.php?role=$role\"$class>" . $name . '</a>'; +} +echo implode(' |</li>', $role_links) . '</li>'; +unset($role_links); +?> +</ul> + <p id="post-search"> + <input type="text" id="post-search-input" name="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> + <input type="submit" value="<?php _e( 'Search Users' ); ?>" class="button" /> + </p> + +<div class="tablenav"> + +<?php if ( $wp_user_search->results_are_paged() ) : ?> + <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div> +<?php endif; ?> + +<div class="alignleft"> +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> +<select name="new_role"><option value=''><?php _e('Change role to…') ?></option>"<?php wp_dropdown_roles(); ?></select> +<input type="submit" value="<?php _e('Change'); ?>" name="changeit" class="button-secondary" /> +<?php wp_nonce_field('bulk-users'); ?> +</div> + +<br class="clear" /> +</div> + +<br class="clear" /> <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?> <div class="error"> @@ -489,85 +451,61 @@ default: <p><a href="users.php"><?php _e('« Back to All Users'); ?></a></p> <?php endif; ?> - <h3><?php - if ( 0 == $wp_user_search->first_user && $wp_user_search->total_users_for_query <= 50 ) - printf(__('%3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query); - else - printf(__('%1$s – %2$s of %3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query); ?></h3> - - <?php if ( $wp_user_search->results_are_paged() ) : ?> - <div class="user-paging-text"><p><?php $wp_user_search->page_links(); ?></p></div> - <?php endif; ?> - -<form action="" method="post" name="updateusers" id="updateusers"> -<?php wp_nonce_field('bulk-users') ?> <table class="widefat"> -<?php -foreach($roleclasses as $role => $roleclass) { - uksort($roleclass, "strnatcasecmp"); -?> -<tbody> -<tr> -<?php if ( !empty($role) ) : ?> - <th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> -<?php else : ?> - <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></em></h3></th> -<?php endif; ?> -</tr> +<thead> <tr class="thead"> - <th><?php _e('ID') ?></th> + <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /> </th> <th><?php _e('Username') ?></th> <th><?php _e('Name') ?></th> <th><?php _e('E-mail') ?></th> - <th><?php _e('Website') ?></th> - <th colspan="2" style="text-align: center"><?php _e('Actions') ?></th> + <th><?php _e('Role') ?></th> + <th class="num"><?php _e('Posts') ?></th> </tr> -</tbody> -<tbody id="role-<?php echo $role; ?>"><?php +</thead> +<tbody id="users" class="list:user user-list"> +<?php $style = ''; -foreach ( (array) $roleclass as $user_object ) { +foreach ( $wp_user_search->get_results() as $userid ) { + $user_object = new WP_User($userid); + $roles = $user_object->roles; + $role = array_shift($roles); + $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; - echo "\n\t" . user_row($user_object, $style); + echo "\n\t" . user_row($user_object, $style, $role); } ?> - </tbody> -<?php } ?> </table> +<div class="tablenav"> + <?php if ( $wp_user_search->results_are_paged() ) : ?> - <div class="user-paging-text"><p><?php $wp_user_search->page_links(); ?></p></div> + <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div> <?php endif; ?> - <h3><?php _e('Update Selected'); ?></h3> - <ul style="list-style:none;"> - <li><input type="radio" name="action" id="action0" value="removeuser" /> <label for="action0"><?php _e('Remove checked users.'); ?></label></li> - <li> - <input type="radio" name="action" id="action1" value="promote" /> <label for="action1"><?php _e('Set the Role of checked users to:'); ?></label> - <select name="new_role" onchange="getElementById('action1').checked = 'true'"><?php wp_dropdown_roles(); ?></select> - </li> - </ul> - <p class="submit" style="width: 420px"> - <?php echo $referer; ?> - <input type="submit" value="<?php _e('Bulk Update »'); ?>" /> - </p> +<br class="clear" /> +</div> + </form> <?php endif; ?> + </div> <?php if ( is_wp_error($add_user_errors) ) { foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) { $var = 'new_' . $var; - $$var = attribute_escape(stripslashes($_POST[$formpost])); + $$var = attribute_escape(stripslashes($_REQUEST[$formpost])); } unset($name); } ?> +<br class="clear" /> + <?php if( apply_filters('show_adduser_fields', true) ) {?> <div class="wrap"> -<h2><?php _e('Add User From Community') ?></h2> +<h2 id="add-new-user"><?php _e('Add User From Community') ?></h2> <div class="narrow"> <form action="" method="post" name="adduser" id="adduser"> <?php wp_nonce_field('add-user') ?> diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php index 30d687b..4a8751d 100644 --- a/wp-admin/widgets.php +++ b/wp-admin/widgets.php @@ -1,359 +1,321 @@ <?php -require_once 'admin.php'; +require_once( 'admin.php' ); +require_once(ABSPATH . 'wp-admin/includes/widgets.php'); if ( ! current_user_can('switch_themes') ) wp_die( __( 'Cheatin’ uh?' )); -wp_enqueue_script('interface'); +wp_enqueue_script( array( 'wp-lists', 'admin-widgets' ) ); -function wp_widgets_admin_head() { - global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls; -?> - <?php wp_admin_css( 'css/widgets' ); ?> - <!--[if IE 7]> - <style type="text/css"> - #palette { float: <?php echo ( get_bloginfo( 'text_direction' ) == 'rtl' ) ? 'right' : 'left'; ?>; } - </style> - <![endif]--> -<?php +do_action( 'sidebar_admin_setup' ); - $cols = array(); - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $cols[] = '\'' . $index . '\''; - } - $cols = implode( ', ', $cols ); +$title = __( 'Widgets' ); +$parent_file = 'themes.php'; - $widgets = array(); - foreach ( $wp_registered_widgets as $name => $widget ) { - $widgets[] = '\'' . $widget['id'] . '\''; - } - $widgets = implode( ', ', $widgets ); +// $sidebar = What sidebar are we editing? +if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) { + $sidebar = attribute_escape( $_GET['sidebar'] ); +} elseif ( is_array($wp_registered_sidebars) && !empty($wp_registered_sidebars) ) { + // By default we look at the first defined sidebar + $sidebar = array_shift( array_keys($wp_registered_sidebars) ); +} else { + // If no sidebars, die. + require_once( 'admin-header.php' ); ?> -<script type="text/javascript"> -// <![CDATA[ - var cols = [<?php echo $cols; ?>]; - var widgets = [<?php echo $widgets; ?>]; - var controldims = new Array; - <?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?> - controldims['#<?php echo $widget['id']; ?>control'] = new Array; - controldims['#<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>; - controldims['#<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>; - <?php endforeach; ?> - function initWidgets() { - <?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?> - jQuery('#<?php echo $widget['id']; ?>popper').click(function() {popControl('#<?php echo $widget['id']; ?>control');}); - jQuery('#<?php echo $widget['id']; ?>closer').click(function() {unpopControl('#<?php echo $widget['id']; ?>control');}); - if ( true && window.opera ) - jQuery('#<?php echo $widget['id']; ?>control').css('border','1px solid #bbb'); - <?php endforeach; ?> - jQuery('#shadow').css('opacity','0'); - jQuery(widgets).each(function(o) {o='#widgetprefix-'+o; jQuery(o).css('position','relative');} ); - } - function resetDroppableHeights() { - var max = 6; - jQuery.map(cols, function(o) { - var c = jQuery('#' + o + ' li').length; - if ( c > max ) max = c; - }); - var maxheight = 35 * ( max + 1); - jQuery.map(cols, function(o) { - height = 0 == jQuery('#' + o + ' li').length ? maxheight - jQuery('#' + o + 'placemat').height() : maxheight; - jQuery('#' + o).height(height); - }); - } - function maxHeight(elm) { - htmlheight = document.body.parentNode.clientHeight; - bodyheight = document.body.clientHeight; - var height = htmlheight > bodyheight ? htmlheight : bodyheight; - jQuery(elm).height(height); - } - function getViewportDims() { - var x,y; - if (self.innerHeight) { // all except Explorer - x = self.innerWidth; - y = self.innerHeight; - } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode - x = document.documentElement.clientWidth; - y = document.documentElement.clientHeight; - } else if (document.body) { // other Explorers - x = document.body.clientWidth; - y = document.body.clientHeight; - } - return new Array(x,y); - } - function dragChange(o) { - var p = getViewportDims(); - var screenWidth = p[0]; - var screenHeight = p[1]; - var elWidth = parseInt( jQuery(o).css('width') ); - var elHeight = parseInt( jQuery(o).css('height') ); - var elLeft = parseInt( jQuery(o).css('left') ); - var elTop = parseInt( jQuery(o).css('top') ); - if ( screenWidth < ( parseInt(elLeft) + parseInt(elWidth) ) ) - jQuery(o).css('left', ( screenWidth - elWidth ) + 'px' ); - if ( screenHeight < ( parseInt(elTop) + parseInt(elHeight) ) ) - jQuery(o).css('top', ( screenHeight - elHeight ) + 'px' ); - if ( elLeft < 1 ) - jQuery(o).css('left', '1px'); - if ( elTop < 1 ) - jQuery(o).css('top', '1px'); - } - function popControl(elm) { - var x = ( document.body.clientWidth - controldims[elm]['width'] ) / 2; - var y = ( document.body.parentNode.clientHeight - controldims[elm]['height'] ) / 2; - jQuery(elm).css({display: 'block', width: controldims[elm]['width'] + 'px', height: controldims[elm]['height'] + 'px', position: 'absolute', right: x + 'px', top: y + 'px', zIndex: '1000' }); - jQuery(elm).attr('class','control'); - jQuery('#shadow').click(function() {unpopControl(elm);}); - window.onresize = function(){maxHeight('#shadow');dragChange(elm);}; - popShadow(); - } - function popShadow() { - maxHeight('#shadow'); - jQuery('#shadow').css({zIndex: '999', display: 'block'}); - jQuery('#shadow').fadeTo('fast', 0.2); - } - function unpopShadow() { - jQuery('#shadow').fadeOut('fast', function() {jQuery('#shadow').hide()}); - } - function unpopControl(el) { - jQuery(el).attr('class','hidden'); - jQuery(el).hide(); - unpopShadow(); - } - function serializeAll() { - <?php $i = 0; foreach ( $wp_registered_sidebars as $index => $sidebar ) : $i++; ?> - var serial<?php echo $i ?> = jQuery.SortSerialize('<?php echo $index ?>'); - jQuery('#<?php echo $index ?>order').attr('value',serial<?php echo $i ?>.hash.replace(/widgetprefix-/g, '')); - <?php endforeach; ?> - } - function updateAll() { - jQuery.map(cols, function(o) { - if ( jQuery('#' + o + ' li').length ) - jQuery('#'+o+'placemat span.handle').hide(); - else - jQuery('#'+o+'placemat span.handle').show(); - }); - resetDroppableHeights(); - } - jQuery(document).ready( function() { - updateAll(); - initWidgets(); - }); -// ]]> -</script> + + <div class="error"> + <p><?php _e( 'No Sidebars Defined' ); ?></p> + </div> + + <div class="wrap"> + <p><?php _e( 'You are seeing this message because the theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://automattic.com/code/widgets/themes/">follow these instructions</a>.' ); /* TODO: article on codex */; ?></p> + </div> + <?php + require_once( 'admin-footer.php' ); + exit; } -add_action( 'admin_head', 'wp_widgets_admin_head' ); -do_action( 'sidebar_admin_setup' ); -function wp_widget_draggable( $name ) { - global $wp_registered_widgets, $wp_registered_widget_controls; +// These are the widgets grouped by sidebar +$sidebars_widgets = wp_get_sidebars_widgets(); +if ( empty( $sidebars_widgets ) ) + $sidebars_widgets = wp_get_widget_defaults(); - if ( !isset( $wp_registered_widgets[$name] ) ) { - return; - } +// for the sake of PHP warnings +if ( empty( $sidebars_widgets[$sidebar] ) ) + $sidebars_widgets[$sidebar] = array(); + +$http_post = 'post' == strtolower($_SERVER['REQUEST_METHOD']); + +// We're updating a sidebar +if ( $http_post && isset($sidebars_widgets[$_POST['sidebar']]) ) { + check_admin_referer( 'edit-sidebar_' . $_POST['sidebar'] ); + + /* Hack #1 + * The widget_control is overloaded. It updates the widget's options AND echoes out the widget's HTML form. + * Since we want to update before sending out any headers, we have to catch it with an output buffer, + */ + ob_start(); + /* There can be multiple widgets of the same type, but the widget_control for that + * widget type needs only be called once if it's a multi-widget. + */ + $already_done = array(); + + foreach ( $wp_registered_widget_controls as $name => $control ) { + if ( in_array( $control['callback'], $already_done ) ) + continue; + + if ( is_callable( $control['callback'] ) ) { + call_user_func_array( $control['callback'], $control['params'] ); + $control_output = ob_get_contents(); + if ( false !== strpos( $control_output, '%i%' ) ) // if it's a multi-widget, only call control function once. + $already_done[] = $control['callback']; + } + + ob_clean(); + } + ob_end_clean(); - $sanitized_name = sanitize_title( $wp_registered_widgets[$name]['id'] ); - $link_title = __( 'Configure' ); - $popper = ( isset( $wp_registered_widget_controls[$name] ) ) - ? ' <div class="popper" id="' . $sanitized_name . 'popper" title="' . $link_title . '">≡</div>' - : ''; + // Prophylactic. Take out empty ids. + foreach ( (array) $_POST['widget-id'] as $key => $val ) + if ( !$val ) + unset($_POST['widget-id'][$key]); - $output = '<li class="module" id="widgetprefix-%1$s"><span class="handle">%2$s</span></li>'; + // Reset the key numbering and store + $new_sidebar = isset( $_POST['widget-id'] ) && is_array( $_POST['widget-id'] ) ? array_values( $_POST['widget-id'] ) : array(); + $sidebars_widgets[$_POST['sidebar']] = $new_sidebar; + wp_set_sidebars_widgets( $sidebars_widgets ); - printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper ); + wp_redirect( add_query_arg( 'message', 'updated' ) ); + exit; } -$title = __( 'Widgets' ); -$parent_file = 'themes.php'; -require_once 'admin-header.php'; -if ( count( $wp_registered_sidebars ) < 1 ) { -?> - <div class="wrap"> - <h2><?php _e( 'No Sidebars Defined' ); ?></h2> - <p><?php _e( 'You are seeing this message because the theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://automattic.com/code/widgets/themes/">follow these instructions</a>.' ); /* TODO: article on codex */; ?></p> - </div> -<?php +// What widget (if any) are we editing +$edit_widget = -1; + +$query_args = array('add', 'remove', 'key', 'edit', '_wpnonce', 'message', 'base' ); + +if ( isset($_GET['add']) && $_GET['add'] ) { + // Add to the end of the sidebar + $control_callback; + if ( isset($wp_registered_widgets[$_GET['add']]) ) { + check_admin_referer( "add-widget_$_GET[add]" ); + $sidebars_widgets[$sidebar][] = $_GET['add']; + wp_set_sidebars_widgets( $sidebars_widgets ); + } elseif ( isset($_GET['base']) && isset($_GET['key']) ) { // It's a multi-widget + check_admin_referer( "add-widget_$_GET[add]" ); + // Copy minimal info from an existing instance of this widget to a new instance + foreach ( $wp_registered_widget_controls as $control ) { + if ( $_GET['base'] === $control['id_base'] ) { + $control_callback = $control['callback']; + $num = (int) $_GET['key']; + $control['params'][0]['number'] = $num; + $control['id'] = $control['id_base'] . '-' . $num; + $wp_registered_widget_controls[$control['id']] = $control; + $sidebars_widgets[$sidebar][] = $control['id']; + break; + } + } + } - require_once 'admin-footer.php'; + // it's a multi-widget. The only way to add multi-widgets without JS is to actually submit POST content... + // so here we go + if ( is_callable( $control_callback ) ) { + require_once( 'admin-header.php' ); + ?> + <div class="wrap"> + <h2><?php _e( 'Add Widget' ); ?></h2> + <br /> + <form action="<?php echo clean_url( remove_query_arg( $query_args ) ); ?>" method="post"> + + <ul class="widget-control-list"> + <li class="widget-list-control-item"> + <h4 class="widget-title"><?php echo $control['name']; ?></h4> + <div class="widget-control" style="display: block;"> + <?php + call_user_func_array( $control_callback, $control['params'] ); + ?> + <div class="widget-control-actions"> + <input type="submit" class="button" value="<?php _e( 'Add Widget' ); ?>" /> + <input type="hidden" id='sidebar' name='sidebar' value="<?php echo $sidebar; ?>" /> + <?php wp_nonce_field ( 'edit-sidebar_' . $sidebar ); + foreach ( $sidebars_widgets[$sidebar] as $sidebar_widget_id ) : ?> + <input type="hidden" name='widget-id[]' value="<?php echo $sidebar_widget_id; ?>" /> + <?php endforeach; ?> + </div> + </div> + </li> + </ul> + </form> + </div> + <?php + + require_once( 'admin-footer.php' ); + exit; + } + wp_redirect( remove_query_arg( $query_args ) ); + exit; +} elseif ( isset($_GET['remove']) && $_GET['remove'] && isset($_GET['key']) && is_numeric($_GET['key']) ) { + // Remove from sidebar the widget of type $_GET['remove'] and in position $_GET['key'] + $key = (int) $_GET['key']; + if ( -1 < $key && ( $keys = array_keys($sidebars_widgets[$sidebar], $_GET['remove']) ) && in_array($key, $keys) ) { + check_admin_referer( "remove-widget_$_GET[remove]" ); + unset($sidebars_widgets[$sidebar][$key]); + $sidebars_widgets[$sidebar] = array_values($sidebars_widgets[$sidebar]); + wp_set_sidebars_widgets( $sidebars_widgets ); + } + wp_redirect( remove_query_arg( $query_args ) ); exit; +} elseif ( isset($_GET['edit']) && $_GET['edit'] && isset($_GET['key']) && is_numeric($_GET['key']) ) { + // Edit widget of type $_GET['edit'] and position $_GET['key'] + $key = (int) $_GET['key']; + if ( -1 < $key && ( $keys = array_keys($sidebars_widgets[$sidebar], $_GET['edit']) ) && in_array($key, $keys) ) + $edit_widget = $key; } -$sidebars_widgets = wp_get_sidebars_widgets(); +// Total number of registered sidebars +$sidebar_widget_count = count($sidebars_widgets[$sidebar]); -if ( empty( $sidebars_widgets ) ) { - $sidebars_widgets = wp_get_widget_defaults(); -} +// This is sort of lame since "widget" won't be converted to "widgets" in the JS +if ( 1 < $sidebars_count = count($wp_registered_sidebars) ) + $sidebar_info_text = __ngettext( 'You are using %1$s widget in the "%2$s" sidebar.', 'You are using %1$s widgets in the "%2$s" sidebar.', $sidebar_widget_count ); +else + $sidebar_info_text = __ngettext( 'You are using %1$s widget in the sidebar.', 'You are using %1$s widgets in the sidebar.', $sidebar_widget_count ); -if ( isset( $_POST['action'] ) ) { - check_admin_referer( 'widgets-save-widget-order' ); - switch ( $_POST['action'] ) { - case 'default' : - $sidebars_widgets = wp_get_widget_defaults(); - wp_set_sidebars_widgets( $sidebars_widgets ); - break; +$sidebar_info_text = sprintf( wp_specialchars( $sidebar_info_text ), "<span id='widget-count'>$sidebar_widget_count</span>", $wp_registered_sidebars[$sidebar]['name'] ); - case 'save_widget_order' : - $sidebars_widgets = array(); +$page = isset($_GET['apage']) ? abs( (int) $_GET['apage'] ) : 1; - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $postindex = $index . 'order'; +/* TODO: Paginate widgets list +$page_links = paginate_links( array( + 'base' => add_query_arg( 'apage', '%#%' ), + 'format' => '', + 'total' => ceil(($total = 105 )/ 10), + 'current' => $page +)); +*/ +$page_links = ' '; - parse_str( $_POST[$postindex], $order ); +// Unsanitized! +$widget_search = isset($_GET['s']) ? $_GET['s'] : false; - $new_order = $order[$index]; +// Not entirely sure what all should be here +$show_values = array( + '' => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ), + 'unused' => __( 'Show unused widgets' ), + 'used' => __( 'Show used widgets' ) +); - if ( is_array( $new_order ) ) { - foreach ( $new_order as $sanitized_name ) { - foreach ( $wp_registered_widgets as $name => $widget ) { - if ( $sanitized_name == $widget['id'] ) { - $sidebars_widgets[$index][] = $name; - } - } - } - } - } +$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false; - wp_set_sidebars_widgets( $sidebars_widgets ); - break; - } -} -ksort( $wp_registered_widgets ); +$messages = array( + 'updated' => __('Changes saved.') +); -$inactive_widgets = array(); +require_once( 'admin-header.php' ); -foreach ( $wp_registered_widgets as $name => $widget ) { - $is_active = false; +if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?> - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) { - $is_active = true; - break; - } - } +<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> - if ( !$is_active ) { - $inactive_widgets[] = $name; - } -} +<?php endif; ?> -$containers = array( 'palette' ); +<div class="wrap"> -foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $containers[] = $index; -} + <form id="widgets-filter" action="" method="get"> -$c_string = ''; + <h2><?php _e( 'Widgets' ); ?></h2> + <p id="widget-search"> + <input type="text" id="widget-search-input" name="s" value="<?php echo attribute_escape( $widget_search ); ?>" /> + <input type="submit" class="button" value="<?php _e( 'Search Widgets' ); ?>" /> + </p> -foreach ( $containers as $container ) { - $c_string .= '"' . $container . '",'; -} + <div class="widget-liquid-left-holder"> + <div id="available-widgets-filter" class="widget-liquid-left"> + <h3><?php _e('Available Widgets'); ?></h3> + <div class="nav"> + <select name="show"> +<?php foreach ( $show_values as $show_value => $show_text ) : $show_value = attribute_escape( $show_value ); ?> + <option value='<?php echo $show_value; ?>'<?php selected( $show_value, $show ); ?>><?php echo wp_specialchars( $show_text ); ?></option> +<?php endforeach; ?> + </select> + <input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" /> + <p class="pagenav"> + <?php echo $page_links; ?> + </p> + </div> + </div> + </div> -$c_string = substr( $c_string, 0, -1 ); + <div id="available-sidebars" class="widget-liquid-right"> + <h3><?php _e('Current Widgets'); ?></h3> + + <div class="nav"> + <select id="sidebar-selector" name="sidebar"> +<?php foreach ( $wp_registered_sidebars as $sidebar_id => $registered_sidebar ) : $sidebar_id = attribute_escape( $sidebar_id ); ?> + <option value='<?php echo $sidebar_id; ?>'<?php selected( $sidebar_id, $sidebar ); ?>><?php echo wp_specialchars( $registered_sidebar['name'] ); ?></option> +<?php endforeach; ?> + </select> + <input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" /> + </div> -if ( isset( $_POST['action'] ) ) { -?> - <div class="fade updated" id="message"> - <p><?php printf( __( 'Sidebar updated. <a href="%s">View site »</a>' ), get_bloginfo( 'url' ) . '/' ); ?></p> </div> -<?php -} -?> - <div class="wrap"> - <h2><?php _e( 'Sidebar Arrangement' ); ?></h2> - <p><?php _e( 'You can drag and drop widgets onto your sidebar below.' ); ?></p> + </form> - <form id="sbadmin" method="post" onsubmit="serializeAll();"> - <p class="submit"> - <input type="submit" value="<?php _e( 'Save Changes »' ); ?>" /> - </p> - <div id="zones"> - <?php - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - ?> - <input type="hidden" id="<?php echo $index; ?>order" name="<?php echo $index; ?>order" value="" /> - - <div class="dropzone"> - <h3><?php echo $sidebar['name']; ?></h3> - - <div id="<?php echo $index; ?>placemat" class="placemat"> - <span class="handle"> - <h4><?php _e( 'Default Sidebar' ); ?></h4> - <?php _e( 'Your theme will display its usual sidebar when this box is empty. Dragging widgets into this box will replace the usual sidebar with your customized sidebar.' ); ?> - </span> - </div> + <div id="widget-content" class="widget-liquid-left-holder"> + + <div id="available-widgets" class="widget-liquid-left"> - <ul id="<?php echo $index; ?>"> - <?php - if ( is_array( $sidebars_widgets[$index] ) ) { - foreach ( $sidebars_widgets[$index] as $name ) { - wp_widget_draggable( $name ); - } - } - ?> - </ul> - </div> - <?php - } - ?> + <?php wp_list_widgets( $show, $widget_search ); // This lists all the widgets for the query ( $show, $search ) ?> + <div class="nav"> + <p class="pagenav"> + <?php echo $page_links; ?> + </p> </div> + </div> + </div> - <div id="palettediv"> - <h3><?php _e( 'Available Widgets' ); ?></h3> + <form id="widget-controls" action="" method="post"> - <ul id="palette"> - <?php - foreach ( $inactive_widgets as $name ) { - wp_widget_draggable( $name ); - } - ?> - </ul> - </div> + <div id="current-widgets-head" class="widget-liquid-right"> - <script type="text/javascript"> - // <![CDATA[ - jQuery(document).ready(function(){ - <?php foreach ( $containers as $container ) { ?> - jQuery('ul#<?php echo $container; ?>').Sortable({ - accept: 'module', activeclass: 'activeDraggable', opacity: 0.8, revert: true, onStop: updateAll - }); - <?php } ?> - }); - // ]]> - </script> - - <p class="submit"> - <?php wp_nonce_field( 'widgets-save-widget-order' ); ?> - <input type="hidden" name="action" id="action" value="save_widget_order" /> - <input type="submit" value="<?php _e( 'Save Changes »' ); ?>" /> - </p> + <div id="sidebar-info"> + <p><?php echo $sidebar_info_text; ?></p> + <p><?php _e( 'Add more from the Available Widgets section.' ); ?></p> + </div> - <div id="controls"> - <?php foreach ( $wp_registered_widget_controls as $name => $widget ) { ?> - <div class="hidden" id="<?php echo $widget['id']; ?>control"> - <span class="controlhandle"><?php echo $widget['name']; ?></span> - <span id="<?php echo $widget['id']; ?>closer" class="controlcloser">×</span> - <div class="controlform"> - <?php call_user_func_array( $widget['callback'], $widget['params'] ); ?> - </div> - </div> - <?php } ?> - </div> - </form> + </div> + + <div id="current-widgets" class="widget-liquid-right"> + <div id="current-sidebar"> + + <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?> - <br class="clear" /> + </div> + + <p class="submit"> + <input type="hidden" id='sidebar' name='sidebar' value="<?php echo $sidebar; ?>" /> + <input type="hidden" id="generated-time" name="generated-time" value="<?php echo time() - 1199145600; // Jan 1, 2008 ?>" /> + <input type="submit" name="save-widgets" value="<?php _e( 'Save Changes' ); ?>" /> +<?php + wp_nonce_field( 'edit-sidebar_' . $sidebar ); +?> + </p> </div> - <div id="shadow"> </div> + </form> + +</div> + +<?php do_action( 'sidebar_admin_page' ); ?> - <?php do_action( 'sidebar_admin_page' ); ?> +<?php require_once( 'admin-footer.php' ); ?> -<?php require_once 'admin-footer.php'; ?> diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 2b06951..bf7e63f 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -1,1350 +1,1462 @@ -* html #poststuff { - height: 100%; /* kill peekaboo bug in IE */ +#plugins .name { + font-weight: bold; } -/* This is the Holly Hack \*/ -* html .wrap { height: 1% } -/* For Win IE's eyes only */ - -body { - border: none; -} -a { - border-bottom: 1px solid #69c; - color: #00019b; - text-decoration: none; +#plugins p { + margin: 0 4px; + padding: 0; } -a.delete:hover { - background: #c00; - color: #fff; +#plugins .togl { + width: 150px; + border-right-width: 1px; + border-right-style: solid; } -#devnews h4 { - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 18px; - font-weight: normal; +.import-system { + font-size: 16px; } -#planetnews ul { - list-style: none; - margin: 0; +#uploading { + border-style: none; padding: 0; + margin-bottom: 16px; + height: 18em; + width: 100%; } -#planetnews li { - width: 17%; - margin: 1%; - float: left; +form#upload th { + text-align: right; } -#planetnews li a { - display: block; - padding: .5em; - background: #ddd; - height: 6em; - overflow: hidden; +form#upload #post_content, form#upload #post_title { + width: 250px; } -#planetnews cite { - font-size: 11px; +.form-invalid input { + border-width: 1px; !important + border-style: solid; !important } -#planetnews li .post { - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 18px; - display: block; - height: 60px; - overflow: hidden; -} -#planetnews .hidden { - display: none; +form#upload #post_content { + height: 50px; } -.readmore { - clear: both; - text-align: right; - margin-right: 5em; +.attpreview { + width: 1px; /* hug */ + text-align: center; } -.widefat { - width: 100%; +.anchors { + margin: 10px 20px 10px 20px; } -.widefat td, .widefat th { - padding: 5px 6px; +.available-theme { + width: 30%; + margin: 0 1em; + float: left; + text-align: center; + height: 28em; + overflow: hidden; } -.widefat th { - text-align: left; +.available-theme a.screenshot { + width: 250px; + height: 200px; + display: block; + margin: auto; + margin-bottom: 10px; + overflow: hidden; + border-width: 1px; + border-style: solid; } -.plugins p { - margin: 4px; - padding: 0; +.available-theme img { + width: 100%; } -.plugins .name { - font-size: 16px; +.checkbox { + border: none; + margin: 0; + padding: 0; } -.import-system { - font-size: 16px; +.code { + font-family: "Courier New", Courier, monospace; } -thead, .thead { - background: #dfdfdf +.commentlist li { + padding: 1em 1em .2em; + margin: 0; + border-bottom-width: 1px; + border-bottom-style: solid; } -#import-upload-form { - margin: auto; - background: #eee; - padding: 1em; +.commentlist li li { + border-bottom: 0px; + padding: 0; } -a.view, a.edit, a.delete, a.view:hover, a.edit:hover, a.delete:hover { - border-bottom: none; - display: block; - padding: 5px 0; - text-align: center; +.commentlist p { + padding: 0; + margin: 0 0 .8em; } -a.view:hover, a.edit:hover { - background: #ccc; - color: #036; +.post-categories { + display: inline; + margin: 0; + padding: 0; } -a:visited { - color: #004; +.post-categories li { + display: inline; } -a:hover { - color: #069; +.quicktags, .search { + font: 12px Georgia, "Times New Roman", Times, serif; } -body { - background: #f9fcfe; - color: #000; +.submit { + border-top: 1px solid #ccc; + padding: 1.5em 0 0 0; + margin: 10px 0 0 0; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; + -moz-border-radius-bottomright: 3px; + -khtml-border-bottom-right-radius: 3px; + -webkit-border-bottom-right-radius: 3px; + border-bottom-right-radius: 3px; +} + +.side-info { margin: 0; - padding: 0; + padding: 4px; + font-size: 11px; } -body, td { - font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; +.side-info h5 { + padding-bottom: 7px; + font-size: 14px; + margin: 12px 2px 5px; + border-bottom-width: 1px; + border-bottom-style: solid; } -fieldset { - border: none; - padding: 3px; +.side-info ul { + margin: 0; + padding-left: 18px; + list-style: square; } -fieldset label.selectit { - display: block; - font-size: 11px; - padding: 0 2px; +.submit input, .button, .button-secondary, .button-highlighted { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 3px 5px; + font-size: 12px; + line-height: 1.5em; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + cursor: pointer; + text-decoration: none; } -fieldset label.selectit:hover { - background: #e9e9e9; +.button-highlighted { + font-weight: bold; } -fieldset legend { - padding: .1em .3em; +#wpcontent select { + font: 12px/20px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 2px; + + border-width: 1px; + border-style: solid; + height: 2em; + vertical-align:top; } -fieldset.options { - padding: 1em; +.approve { + display: none; } -fieldset.options legend { - font-size: 1.5em; - font-weight: bold; - font-family: Georgia, "Times New Roman", Times, serif; +.unapproved .approve { + display: inline; } -form, label input { - margin: 0; - padding: 0; +.updated a { + border-bottom-width: 1px; + border-bottom-style: solid; } -h2 { - color: #333; - font: normal 32px Georgia, "Times New Roman", Times, serif; - margin: 5px 10px; - background: url( images/heading-bg.gif ) repeat-x bottom; + +.unapproved .unapprove { + display: none; } -img { - border: 0; +.narrow { + width: 70%; + margin-bottom: 40px; } -input:focus, textarea:focus, label:focus { - background: #fff; - border: 1px solid #686868; +.narrow p { + line-height: 150%; } -label { - cursor: pointer; + +table .vers { + text-align: center; } -li, dd { - margin-bottom: 6px; +textarea.all-options, input.all-options { + width: 250px; } -p, li, dl, dd, dt { - line-height: 140%; +#postdiv, #titlediv, #guiddiv, #poststuff .stuffbox { + margin: 0 8px 0 0; + padding: 0; } -textarea, input, select { - background: #f4f4f4; - border: 1px solid #b2b2b2; - color: #000; - font: 13px Verdana, Arial, Helvetica, sans-serif; - margin: 1px; - padding: 3px; +#titlediv, #namediv, #poststuff #namediv { + margin-top: 10px; } -#uploading { - border-style: none; +#postdivrich { + margin: 0; padding: 0; - margin-bottom: 16px; - height: 18em; +} + +#content { + margin: 0; width: 100%; } -form#upload th { - text-align: right; +#editorcontainer #content { + padding: 0; + line-height: 150%; + border: 0 none; + outline: none; } -form#upload #post_content, form#upload #post_title { - width: 250px; +#editorcontainer { + padding: 6px; + border-style: none solid solid; + border-width: 1px; + border-collapse: separate; } -form#upload #post_content { - height: 50px; +#currenttheme img { + float: left; + margin-right: 1em; + margin-bottom: 1.5em; + width: 300px; + border-width: 1px; + border-style: solid; } -.attpreview { - width: 1px; /* hug */ - text-align: center; +#quicktags { + padding: 0; + border: 0 none; } -.alignleft { - float: left +#quicktags #ed_toolbar { + padding: 2px 4px; } -.alignright { - float: right; +#ed_toolbar input { + margin: 3px 2px 2px; + padding: 2px 4px; + line-height: 18px; + display: inline-block; } -.alternate { - background: #f1f1f1; +#quicktags #ed_strong { + font-weight: bold; } -.anchors { - margin: 10px 20px 10px 20px; +#quicktags #ed_link { + text-decoration: underline; } -.available-theme { - width: 30%; - margin: 0 1em; - float: left; - text-align: center; - height: 28em; - overflow: hidden; +#quicktags #ed_del { + text-decoration: line-through; } -.available-theme a.screenshot { - width: 250px; - height: 200px; - display: block; - margin: auto; - background: #f1f1f1; - border: 1px solid #ccc; - margin-bottom: 10px; - overflow: hidden; +#quicktags #ed_em { + font-style: italic; } -.available-theme a.screenshot:hover { -/* border: 1px solid #666;*/ +#quicktags #ed_code { + font-family: "Courier New", Courier, mono; + font-size: 1.1em; + vertical-align: top; } -.available-theme img { + +#attachmentlinks textarea { width: 100%; + height: 2.5em; + margin-bottom: 6px; } -.checkbox { - background: #fff; - border: none; +#excerpt, .attachmentlinks { margin: 0; - padding: 0; + height: 4em; + width: 98%; } -.code { - font-family: "Courier New", Courier, monospace; +.plugins p { } -.commentlist li { - border-bottom: 1px solid #ccc; - padding: 1em 1em .2em; - margin: 0; +#login .fullwidth { + width: 320px; } -.commentlist li li { - border-bottom: 0px; +#searchform fieldset { + float: left; + margin: 0 1.5ex 1em 0; padding: 0; } -.commentlist p { - padding: 0; - margin: 0 0 .8em; +#searchform fieldset legend { + padding: 0 0 .2em 1px; } -.clear { - clear: both; - height: 2px; +#searchform #s { + padding: 4px 3px; } -.hidden { - display: none; +#searchform #post-query-submit { + float: left; + margin: 14px 0 1em; + position: relative; + top: .35em; } -.navigation { - display: block; - text-align: center; - margin-top: 10px; - margin-bottom: 30px; +#postcustomstuff .updatemeta, #postcustomstuff .deletemeta { + margin: auto; } -.post-categories { - display: inline; +#postcustomstuff table { margin: 0; - padding: 0; + width: 100%; + border-width: 1px; + border-style: solid; } -.post-categories li, #ed_toolbar { - display: inline; +#postcustomstuff table input, #postcustomstuff table textarea { + width: 95%; } -.quicktags, .search { - background: #ccc; - color: #000; - font: 12px Georgia, "Times New Roman", Times, serif; +#postcustomstuff table #addmetasub { + width: auto; } -.submit input, .submit input:focus, .button, .button:focus { - background: url( images/fade-butt.png ); - border: 3px double #999; - border-left-color: #ccc; - border-top-color: #ccc; - color: #333; - padding: 0.25em; +#poststuff #post-body { + margin-right: 230px; } -.submit input:active, .button:active { - background: #f4f4f4; - border: 3px double #ccc; - border-left-color: #999; - border-top-color: #999; +#save { + width: 15em; } -.button, .button:focus { - padding: 0.15em; +#template div { + margin-right: 190px; } -* html .button { - padding: 0; +* html #template div { + margin-right: 0; } -.submit, .editform th, #postcustomsubmit { - text-align: right; +#template, #template div, #editcat, #addcat { + zoom: 1; } -.optiontable { - width: 100%; +/* A handy div class for hiding controls. +Some browsers will disable them when you +set display:none; */ +.zerosize { + height: 0; + width: 0; + margin: 0; + border: 0; + padding: 0; + overflow: hidden; + position: absolute; } -.optiontable td, .optiontable th { - padding: .5em; +* html #themeselect { + padding: 0 3px; + height: 22px; } -.optiontable th { - width: 33%; - text-align: right; - font-size: 1.3em; - font-weight: normal; +#your-profile fieldset { + border-width: 1px; + border-style: solid; + float: left; + width: 40%; + padding: .5em 2em 1em; + margin: 1em 1em 1em 0; } -.unapproved { - color: #888; +#your-profile fieldset input { + width: 100%; + font-size: 20px; + padding: 2px; } -.unapproved a:link { - color: #b9bcff; +#your-profile fieldset textarea { + width: 100%; + padding: 2px; } -.unapproved a:visited { - color: #696dff; +#your-profile legend { + font-family: Georgia, "Times New Roman", Times, serif; + font-size: 22px; } -.unapproved a:hover { - color: #009ef0; +#your-profile #rich_editing { + border: none; } -.approve { - display: none; +#howto { + font-size: 11px; + margin: 0 5px; + display: block; } -.unapproved .approve { - display: inline; +#ajax-response.alignleft { + margin-left: 2em; } -.unapproved .unapprove { - display: none; -} -.updated, .confirm { - background: #CFEBF7 url(images/notice.gif) no-repeat 1em; - border: 1px solid #2580B2; - margin: 1em 5% 10px; - padding: 0 1em 0 3em; +div.nav { + height: 2em; + padding: 7px 10px; + vertical-align: text-top; + margin: 5px 0; } -.error { - background: #FFEFF7; - border: 1px solid #c69; - margin: 1em 5% 10px; - padding: 0 1em 0 1em; +.nav .button-secondary { + padding: 2px 4px; } -.wrap { - background: #fff; - border: 1px solid #ccc; - clear: both; - margin: 15px 5%; - padding: 1em; +.page-numbers { + padding: 2px 4px; + margin-right: 3px; + border-width: 1px; + border-style: solid; } -.narrow { - width: 450px; - margin: auto; +.page-numbers.current { + font-weight: bold; + border-width: 1px; + border-style: solid; } -.narrow p { - line-height: 150%; +p.pagenav { + margin: 0; + display: inline; } -.wrap h2 { - margin: 0 0 .5em; - clear: both; +.pagenav span { + font-weight: bold; + margin: 0 6px; } -* html .wrap h2 { - margin-top: 1em; +.row-title { + font-size: 12px !important; + font-weight: bold; } -table .vers { - text-align: center; +.comment-column { + margin-left: 5px; } -textarea.all-options, input.all-options { - width: 250px; +.tablenav a.button-secondary { + display: block; + margin: 1px 8px 0 0; } -input.disabled, textarea.disabled { - background: #ccc; +.tablenav .button-secondary { + padding: 2px 4px; + vertical-align: top; } -#adminmenu { - background: #83B4D8; - border-top: 3px solid #448abd; - margin: 0; - padding: .2em .2em .3em 2em; +.tablenav .tablenav-pages a.next, .tablenav .tablenav-pages a.prev { + text-decoration: underline; } -#adminmenu .current, #submenu .current { - font-weight: bold; - text-decoration: none; +.tablenav { + height: 2em; + padding: 7px 10px; + clear: both; + margin-bottom: -10px; + margin-top: 8px; + vertical-align: text-top; } -#adminmenu a { - color: #000; - font-size: 14px; - font-weight: normal; - margin: 0; - padding: 3px 5px; - border-bottom: none; +.tablenav .tablenav-pages { + float: right; + height: 18px; + padding-top: 6px; + font-size: 11px; } -#adminmenu a:hover, #adminmenu a.current { - background: #ddeaf4; - color: #333; +.tablenav .tablenav-pages a { + text-decoration: none; } -#adminmenu li, #submenu li { - display: inline; - line-height: 200%; - list-style: none; +td.media-icon { + vertical-align: middle; text-align: center; - white-space: nowrap; } -#adminmenu a.current { - background: #0d324f; - border-right: 2px solid #4f96c8; - border-top: 1px solid #96c0de; - color: #fff; - padding-bottom: 8px; +td.media-icon img { + max-width: 80px; + max-height: 60px; } -#submenu, #minisub { - background: #0d324f; - border-bottom: none; - margin: 0; - padding: 3px 2em 0 3em; +#update-nag, .plugin-update { + line-height: 29px; + font-size: 12px; + text-align: center; + border-bottom-width: 1px; + border-bottom-style: solid; + border-top-width: 1px; + border-top-style: solid; } -#minisub { - height: 6px; +#update-nag a, .plugin-update a { + font-size: 1.1em; } -#submenu .current { - background: #f9fcfe; - border-top: 1px solid #045290; - border-right: 2px solid #045290; - color: #000; +#pass-strength-result { + padding: 3px 5px 3px 5px; + margin-top: 3px; + text-align: center; + border-width: 1px; + border-style: solid; } -#submenu a { - border: none; - color: #fff; - font-size: 12px; - padding: .3em .4em .4em; +a.view-comment-post-link { + position: absolute; + text-decoration:underline; } -#submenu a:hover { - background: #ddeaf4; - color: #393939; +/* Admin Header */ + +#user_info { + position: absolute; + right: 15px; + top: 11px; + font-size: 11px; } -#submenu li { - line-height: 180%; - height: 25px; +#user_info p { + margin: 0; + padding: 0; } -#categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input { - border: none; +#wphead { + border-top-width: 30px; + border-top-style: solid; } -#postdiv, #titlediv, #guiddiv, #tagdiv { - margin: 0 8px 0 0; - padding: 0; +#wphead a, #dashmenu a, #adminmenu a, #submenu a, #sidemenu a { + text-decoration: none; } -#postdivrich { - margin: 0; - padding: 0; +#wphead #viewsite { + position: absolute; + margin-top: 12px; + margin-left: 10px; +} +#wphead #viewsite a { + font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + padding: 3px 4px; + display: block; + letter-spacing: normal; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } -#content { +#wphead h1 { + font: normal 36px Georgia, "Times New Roman", Times, serif; + padding: 11px 170px 16px 12px; margin: 0; - width: 100%; + margin-right: 15%; } -#postdivrich #content { - padding: 5px; - line-height: 140%; -} +/* menu stuff */ -#titlediv input, #guiddiv input, #tagdiv input { +#dashmenu { margin: 0; - width: 100%; + list-style: none; + position: absolute; + top: 7px; + left: 0; + font-size: 11px; + padding-left: 9px; } -#currenttheme img { - float: left; - border: 1px solid #666; - margin-right: 1em; - margin-bottom: 1.5em; - width: 300px; +#dashmenu a { + padding: 5px 6px; + line-height: 220%; + margin-right: 8px; } -input.delete:hover { - background: #ce0000; - color: #fff; +#dashmenu a.current { + border: none; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; } -#deletebookmarks:hover { - background: #ce0000; - color: #fff; +#adminmenu { + margin: 0; + list-style: none; + padding-left: 11px; + border-bottom-width: 1px; + border-bottom-style: solid; } -#postdivrich #quicktags { - background: #f0f0ee; - padding: 0; - border: 1px solid #ccc; - border-bottom: none; +#adminmenu a { + font-size: 16px; + padding: 5px 7px; + line-height: 30px; } -#postdiv #quicktags { +#adminmenu a.current, #sidemenu a.current { + font-weight: normal; + padding-left: 6px; padding-right: 6px; + -moz-border-radius-topleft: 4px; + -khtml-border-top-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topright: 4px; + -khtml-border-top-right-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + border-width: 1px; + border-style: solid; } -#postdivrich #quicktags { - display: none; +#adminmenu a.current { + border-bottom-width: 2px; } -#quicktags #ed_toolbar { - padding: 0 2px; +#sidemenu { + margin: -30px 15px 0 315px; + list-style: none; + position: relative; + float: right; + padding-left: 10px; + font-size:12px; } -#ed_toolbar input { - background: #fff url( images/fade-butt.png ) repeat-x 0 -2px; - margin: 3px 2px 2px; +#sidemenu a { + padding: 0 7px; + display: block; + float: left; + line-height: 28px; + border-top-width: 1px; + border-top-style: solid; + border-bottom-width: 1px; + border-bottom-style: solid; } -#quicktags #ed_strong { - font-weight: bold; +#dashmenu li, #adminmenu li, #submenu li, #sidemenu li { + display: inline; + line-height: 200%; + list-style: none; + text-align: center; + white-space: nowrap; + margin: 0; + padding: 0; } -#quicktags #ed_link { - color: blue; - text-decoration: underline; +#submenu li { + padding: 0 0 8px 17px; } -#quicktags #ed_del { - text-decoration: line-through; +#adminmenu li a #awaiting-mod { + position: absolute; + margin-left: -0.4em; + margin-top: 0.2em; + font-size: 0.7em; + background-repeat: no-repeat; + background-position: 0 bottom; + height: 0.9em; + width: 1em; } -#quicktags #ed_em { - font-style: italic; +#adminmenu li a .count-0 { + display: none; } -#quicktags #ed_code { - font-family: "Courier New", Courier, mono; - margin-bottom: 3px; +.post-com-count-wrapper { + min-width: 22px; } -#title { - font-size: 1.7em; - padding: 4px 3px; +.post-com-count { + height: 1.3em; + line-height: 1.1em; + display: block; + text-decoration: none; + padding: 0 0 6px; + cursor: pointer; + background-position: center -80px; + background-repeat: no-repeat; } -#postexcerpt div, #attachmentlinks div { - margin-right: 8px; +.post-com-count span { + height: 1.3em; + line-height: 1.2em; + padding: 0 0.5em; + background-color: #bbb; + display: inline-block; + cursor: pointer; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } -#attachmentlinks textarea { - width: 100%; - height: 2.5em; - margin-bottom: 6px; +strong .post-com-count { + background-position: center -55px; } -* html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open { - padding-right: 8px; +.post-com-count:hover { + background-position: center -3px; } -#excerpt, .attachmentlinks { - margin: 0; - height: 4em; - width: 100%; +#adminmenu li a:hover #awaiting-mod { + background-position: -80px bottom; } -#footer { - clear: both; - height: 35px; - padding-left: 40px; - margin: 15px 5%; - background: url('images/logo-ghost.png') no-repeat top left; +#adminmenu li a #awaiting-mod span { + top: -0.8em; + right: 0; + position: absolute; + display: block; + height: 1.3em; + line-height: 1.3em; + padding: 0 0.6em; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } -#footer p { +#submenu { margin: 0; - padding: 5px 0; + list-style: none; + padding: 6px 0 3px 0; } -#login { - position: relative; - background: url('images/login-bkg-tile.gif') no-repeat top center; - color: #fff; - margin: 5em auto 1em; - padding: 20px 0 0; - width: 425px; - _width: 390px; -} - -#login form { - background: url('images/login-bkg-bottom.gif') no-repeat bottom center; - padding: 0 50px 25px; - _width: 325px; - _margin: 0 auto; - min-height: 200px; - height: auto !important; /* min-height fast hack */ - height: 200px; +#submenu li { + font-size: 14px; } -#login #login_error { - background: #0e3350; - border: 1px solid #2571ab; - color: #ebcd4e; - font-size: 11px; - font-weight: bold; - padding: .6em; - width: 310px; - margin: 0 50px; - text-align: center; +#minisub { /* for empty submenus */ + height: 15px; } -#login p { - font-size: 12px; -} +/* end menu stuff */ -#login p.message { - width: 310px; - margin: 0 auto 1em; -} +/* Admin Footer */ -#login #login_error a { - color: #ebcd4e; - border-color: #ebcd4e; +html, body { + height:100%; } - -#login #send { - color: #fff; - text-align: left; - font-weight: normal; - font-size: 1.1em; - _width: 325px; - _margin: 0 auto 15px; +#wpwrap { + position: relative; + min-height: 100%; } - -#login h1 a { - margin: 0 auto; - height: 88px; - width: 320px; - display: block; - border-bottom: none; - text-indent: -9999px; +#wpcontent{ + padding-bottom: 95px; } - -#login .message { - font-size: 10pt; - text-align: center; +#footer { + clear: both; + height: 65px; + padding: 10px 0 0 60px; + margin: 0; + position: relative; + margin-top: -75px; + font-size: 12px; } -#login .register { - font-size: 20px; +#footer p { + margin: 0; + padding: 7px 0; } -#login input { - padding: 4px; +#footer p a { + text-decoration: none; } -.login ul, #protected #login .bottom { - list-style: none; - width: 325px; - margin: 0 auto; - padding: 0; - line-height: 1.2; +#footer p a:hover { + text-decoration: underline; } -.login ul li { - font-size: 11px; -} +/* Tables used on comment.php and option/setting pages */ -.login ul li a { - color: #0d324f; - border: none; +.form-table { + border-collapse: collapse; + margin-top: 1em; + width: 100%; + margin-bottom: -8px; } -#login ul li a:hover { - color: #fff; +.form-table td { + margin-bottom: 9px; + padding: 10px; + line-height: 20px; + border-bottom-width: 8px; + border-bottom-style: solid; + font-size: 11px; } -#login .input { - font-size: 1.8em; - margin-top: 3px; - width: 97%; +.form-table th { + vertical-align: top; + text-align: left; + padding: 10px; + width: 150px; + border-bottom-width: 8px; + border-bottom-style: solid; } -#login p label { - font-size: 11px; +.form-table th.th-full { + width: auto; } -#login #submit { - margin: 0; - font-size: 15px; +.form-table input, .form-table textarea { + border-width: 1px; + border-style: solid; } -.plugins p { +.form-table div.color-option { + display: block; + clear: both; } -#login .fullwidth { - width: 320px; +.form-table input.tog { + margin-top: 2px; + margin-right: 2px; + float: left; } -#searchform fieldset { +.form-table table.color-palette { + vertical-align: bottom; float: left; - margin: 0 1.5ex 1em 0; - padding: 0; + margin: -3px 3px 8px; } -#searchform fieldset legend { - padding: 0 0 .2em 1px; +.form-table .color-palette td { + border-bottom: none; + border: 1px solid #fff; + font-size: 1px; + line-height: 1px; } - -#searchform #s { - padding: 4px 3px; + +#profile-page .form-table textarea { + width: 500px; + margin-bottom: 6px; } -#searchform #post-query-submit { +#pass-strength-result { + width: 197px; float: left; - margin: 14px 0 1em; - position: relative; - top: .35em; + margin-right: 5px; + border: 1px solid #ccc !important; } -#postcustom .updatemeta, #postcustom .deletemeta { - margin: auto; +#profile-page .form-table #rich_editing { + margin-right: 5px } -#postcustom table { - border: 1px solid #ccc; - margin: 0; - width: 100%; +/* Post Screen */ + +#tagsdiv #newtag { + margin-right: 5px; + width: 16em; } -#postcustom table input, #postcustom table textarea { - width: 95%; +#tagchecklist { + margin-left: 10px; + + font-size: 12px; + overflow: auto; } -#poststuff { - margin-right: 16em; +#tagchecklist strong { + margin-left: -8px; + position: absolute; } -#save { - width: 15em; +#tagchecklist span { + margin-right: 25px; + display: block; + float: left; + font-size: 11px; + line-height: 1.8em; + white-space: nowrap; + cursor: default; } -#template div { - margin-right: 190px; +#tagchecklist span a { + margin: 6px 0pt 0pt -9px; + cursor: pointer; + width: 10px; + height: 10px; + display: block; + float: left; + text-indent: -9999px; + overflow: hidden; + position: absolute; } -* html #template div { - margin-right: 0; +.howto { + font-style: italic; + display: block; } -#template, #template div, #editcat, #addcat { - zoom: 1; +.ac_results { + padding: 0; + margin: 0; + list-style: none; + position: absolute; + z-index: 10000; + display: none; + border-width: 1px; + border-style: solid; } -#template textarea { - font: small 'Courier New', Courier, monospace; - width: 97%; +.ac_results li { + padding: 2px 5px; + white-space: nowrap; + text-align: left; } -#templateside { - float: right; - width: 170px; - overflow: hidden; +.ac_over { + cursor: pointer; } -#templateside h3, #postcustom p.submit { - margin: 0; +.ac_match { + text-decoration: underline; } -#templateside ol, #templateside ul { - list-style: none; - margin: .5em; - padding: 0; +#poststuff h2 { + margin-top: 20px; + font-size: 1.5em; + margin-bottom: 15px; + padding: 0 0 3px; } -#user_info { - position: absolute; - right: 1em; - top: 0; - color: #fff; - font-size: .9em; +#poststuff h3 { + font-size: 14px; + font-weight: bold; + padding: 7px; + margin: 0 0 10px; } -#user_info a { - color: #fff; +#poststuff .postbox, #poststuff .stuffbox { + margin-left: 20px; + padding: 2px; + margin-bottom: 20px; + margin-right: 8px; + border-width: 1px; + border-style: solid; } -#wphead { - background: #14568a; - padding: .8em 19em .8em 2em; - color: #c3def1; +#titlediv, #poststuff .postarea { + margin-left: 20px; + margin-bottom: 20px; + margin-right: 8px; } -#wphead a { - color: #fff; +#titlediv { + margin-bottom: 20px; } -#wphead h1 { - font-size: 2.5em; - font-weight: normal; - letter-spacing: -.05em; +#titlediv div.inside { margin: 0; - font-family: Georgia, "Times New Roman", Times, serif; } -#wphead h1 span#viewsite { - font-size: .4em; - letter-spacing: 0; +#titlediv #title { + border: 0; + padding: 0; + font-size: 1.7em; + width: 100%; + outline: none; } -#zeitgeist { - background: #eee; - border: 1px solid #c5c5c5; - float: right; - font-size: 90%; - margin-bottom: .5em; - margin-left: 1em; - margin-top: .5em; - padding: 1em; - width: 40%; +#poststuff #titlewrap { + padding: 2px 3px; + border-width: 1px; + border-style: solid; } -#zeitgeist h2, fieldset legend a { - background: none; +#poststuff .inside { + margin: 0 12px 12px; + font-size: 11px; } -* html #zeitgeist h2 { - padding-top: 10px; +#link_name, #link_url, #link_description { + font-size: 1.7em; + padding: 4px 3px; + width: 98%; } -#zeitgeist h3 { - border-bottom: 1px solid #ccc; - font-size: 16px; - margin: 1em 0 0; +#edit-slug-box { + margin-top: 8px; } -#zeitgeist h3 cite { - font-size: 12px; - font-style: normal; -} +#editable-post-name-full {display: none;} -#zeitgeist li, #zeitgeist p { - margin: .2em 0; -} +#editable-post-name input {width: 16em;} -#zeitgeist ul { - margin: 0 0 .3em .6em; - padding: 0 0 0 .6em; +#edit-slug-buttons a.save { + padding: 6px 4px; + margin-right: 4px; + text-decoration: none; + border-width: 1px; + border-style: solid; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + font-weight: bold; } -.active td { - background: #BEB; -} -.active .name { - background: #9C9; -} -.alternate.active td { - background: #ADA; -} -.alternate.active .name { - background: #8B8; +#poststuff #editor-toolbar { + position: relative; + height: 30px; + margin-top: -41px; } -#namediv, #emaildiv, #uridiv { - float: left; +#poststuff #edButtonPreview, #poststuff #edButtonHTML { + display: block; + height: 20px; + padding: 5px 5px 1px; + margin: 5px 8px 0 0; + float: right; + cursor: pointer; } -#ajax-response { - padding: .5em; +#poststuff #editor-toolbar .active { + font-weight: bold; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; } -/* A handy div class for hiding controls. -Some browsers will disable them when you -set display:none; */ -.zerosize { - height: 0; - width: 0; - margin: 0; - border: 0; - padding: 0; - overflow: hidden; - position: absolute; +#poststuff #media-buttons { + float: right; + margin-right: 20px; + margin-top: 8px; + cursor: default; + line-height: 1; + height: 1.1em; } -/* Box stuff */ -.dbx-clone { - position: absolute; - visibility: hidden; +#poststuff #media-buttons a { + cursor: pointer; + padding: 0 5px 2px 2px; } -.dbx-clone, .dbx-clone .dbx-handle-cursor { - cursor: move !important; + +#poststuff #media-buttons img { + vertical-align: middle; } -.dbx-dummy { + +#poststuff .togbox { + background-position: -10px 16px; + background-repeat: no-repeat; display: block; - width: 0; - height: 0; + height: 37px; + margin-left: -21px; + margin-top: -10px; overflow: hidden; -} -.dbx-group, .dbx-box, .dbx-handle { - position: relative; - display: block; + position: absolute; + text-indent: -9999px; + width: 12px; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; +} + +#poststuff .closed .inside { + display: none; } -#grabit { - width: 188px; +#poststuff .closed h3 { + margin: 0; } -* html #themeselect { - padding: 0 3px; - height: 22px; +#poststuff .closed .togbox { + background-position: 4px 15px; } -/**************************************************************** -avoid padding, margins or borders on dbx-box, -to reduce visual discrepancies between it and the clone. -overall, dbx-box is best left as visually unstyled as possible -*****************************************************************/ -.dbx-box { - margin: 0; - padding: 0; - border: none; +.submitbox { + width: 220px; + float: right; } -/* Can change this */ -#moremeta fieldset, #advancedstuff fieldset { - margin-bottom: 1em; -} -#moremeta fieldset div { - margin: 2px 0 0 0; - padding: 7px; -} -#moremeta { - line-height: 130%; - margin-right: 15px; - position: absolute; - right: 5%; - width: 14.5em; +.submitbox .inside strong { + font-size: 14px; } -#moremeta select { - width: 96%; + +.submitbox .submitdelete { + border-bottom-width: 1px; + border-bottom-style: solid; + text-decoration: none; + margin-left: 8px; + padding-bottom: 1px; } -#slugdiv input, #passworddiv input, #authordiv select, #thumbdiv input, #parentdiv input { - margin-top: .5em; - width: 90%; + +.submitbox #previewview { + padding: 15px 10px; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; } -#moremeta h3, #advancedstuff h3 { - padding: 3px; +.submitbox #previewview a { + padding: 6px; + text-decoration: none; font-weight: normal; - font-size: 13px; + border-bottom: none; + font-size: 14px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } -#advancedstuff div { - margin-top: .5em; +.submitbox .submit { + text-align: left; + padding: 12px 10px 10px 10px; + font-size: 11px; } -#categorydiv ul { - list-style: none; - padding: 0; - margin-left: 10px; +.submitbox .submit a:hover { + border-bottom-width: 1px; + border-bottom-style: solid; } -#categorychecklist { - height: 12em; - overflow: auto; - margin-top: 8px; +.submitbox .submit input { + margin-bottom: 8px; + margin-right: 3px; + padding: 6px 4px; + border: none; } -#categorychecklist li { - margin: 0; - padding: 0; +.submitbox #autosave .error { + margin-top: 10px; } -#ajaxcat input { - border: 1px solid #ccc; -} +/* Categories */ -#your-profile #rich_editing { - border: none; - background: #fff; +#categorydiv #category-adder { + margin-left: 120px; + padding: 4px 0; } -#your-profile fieldset { - border: 1px solid #ccc; - float: left; - width: 40%; - padding: .5em 2em 1em; - margin: 1em 1em 1em 0; +#category-add input, #category-add select { + width: 30%; } -#your-profile fieldset input { - width: 100%; - font-size: 20px; - padding: 2px; +#category-add input#category-add-sumbit { + width: auto; } -#your-profile fieldset textarea { - width: 100%; - padding: 2px; +#categorydiv ul#category-tabs { + float: left; + width: 120px; + text-align: right; + /* Negative margin for the sake of those without JS: all tabs display */ + margin: 0 -120px 0 0; + padding: 0; } -#your-profile legend { - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 22px; +ul#category-tabs li { + padding: 8px; } -/* default box styles */ - -/* toggle state of inner content area */ -.dbx-box-open .dbx-content { - display: block; -} -.dbx-box-closed .dbx-content { - display: none; +ul#category-tabs li.ui-tabs-selected { + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-bottomleft: 3px; + -khtml-border-bottom-left-radius: 3px; + -webkit-border-bottom-left-radius: 3px; + border-bottom-left-radius: 3px; } -#moremeta .dbx-content { - background: url(images/box-butt.gif) no-repeat bottom right; - padding-bottom: 15px; - padding-right: 2px; +ul#category-tabs li.ui-tabs-selected a { + color: #333; + font-weight: bold; + text-decoration: none; } -#moremeta fieldset.dbx-box-closed { - background: url(images/box-butt.gif) no-repeat bottom; - padding-bottom: 9px; +div.ui-tabs-panel { + margin: 0 5px 0 120px; + padding: .5em .9em; + height: 10em; + overflow: auto; + border-width: 4px; + border-style: solid; } -/* handles */ - -.dbx-handle { - background: #2685af; - padding: 6px 1em 2px; - font-size: 12px; +#categorydiv ul { + list-style: none; + padding: 0; margin: 0; - color: #E3EFF5; } -#moremeta .dbx-handle { - padding: 6px 1em 2px; - font-size: 12px; - background: #2685af url(images/box-head.gif) no-repeat right; +#categorydiv ul.categorychecklist ul { + margin-left: 18px; } -#moremeta .dbx-box { - background: url(images/box-bg.gif) repeat-y right; +ul.categorychecklist li { + margin: 0; + padding: 0; + line-height: 19px; } -#advancedstuff h3.dbx-handle { - margin-left: 7px; - margin-bottom: -7px; - padding: 6px 1em 0 3px; - height: 19px; - font-size: 12px; - background: #2685af url(images/box-head-right.gif) no-repeat top right; +#linkcategorydiv #category-adder { + margin-left: 120px; + padding: 4px 0; } -#advancedstuff div.dbx-h-andle-wrapper { - margin: 0 0 0 -7px; - background: #fff url(images/box-head-left.gif) no-repeat top left; +#category-adder h4 { + margin: 0; } -#advancedstuff div.dbx-content { - margin-left: 8px; - background: url(images/box-bg-right.gif) repeat-y right; - padding: 10px 10px 15px 0; +#linkcategorydiv ul#category-tabs { + float: left; + width: 120px; + text-align: right; + /* Negative margin for the sake of those without JS: all tabs display */ + margin: 0 -120px 0 0; + padding: 0; } -#postexcerpt div.dbx-content { - margin-right: 0; - padding-right: 17px; +#linkcategorydiv ul { + list-style: none; + padding: 0; + margin: 0; } -#advancedstuff div.dbx-c-ontent-wrapper { - margin-left: -7px; - margin-right: 0; - background: url(images/box-bg-left.gif) repeat-y left; +#linkcategorydiv ul.categorychecklist ul { + margin-left: 18px; } -#advancedstuff fieldset.dbx-box { - padding-bottom: 9px; - margin-left: 6px; - background: url(images/box-butt-right.gif) no-repeat bottom right; +/* pasitioning etc. */ +form#tags-filter { + position: relative; } -#advancedstuff div.dbx-b-ox-wrapper { - background: url(images/box-butt-left.gif) no-repeat bottom left; +p#tag-search { + position: absolute; + right: 0; + top: 0; + margin: 0; } -#advancedstuff .dbx-box-closed div.dbx-c-ontent-wrapper { - padding-bottom: 2px; - background: url(images/box-butt-left.gif) no-repeat bottom left; +form#posts-filter { + position: relative; } -#advancedstuff .dbx-box { - background: url(images/box-butt-right.gif) no-repeat bottom right; +p#post-search { + position: absolute; + right: 0; + top: 0; + margin: 0; } -/* handle cursors */ -.dbx-handle-cursor { - cursor: move; +#post-search .button, #widget-search .button { + padding: 3px; + font-size: 13px; } -/* toggle images */ -a.dbx-toggle, a.dbx-toggle:visited { - display: block; - overflow: hidden; - background-image: url( images/toggle.gif ); - position: absolute; - top: 0; - right: 0; - background-repeat: no-repeat; - border: 0; - margin: 0; +#posts-filter fieldset { + float: left; + margin: 0 1.5ex 1em 0; padding: 0; } -#moremeta a.dbx-toggle, #moremeta a.dbx-toggle-open:visited { - height: 25px; - width: 27px; - background-position: 0 0; -} - -#moremeta a.dbx-toggle-open, #moremeta a.dbx-toggle-open:visited { - height: 25px; - width: 27px; - background-position: 0 -25px; +#posts-filter fieldset legend { + padding: 0 0 .2em 1px; } -#advancedstuff a.dbx-toggle, #advancedstuff a.dbx-toggle-open:visited { - height: 22px; - width: 22px; - top: 3px; - right: 5px; - background-position: 0 -3px; +.bordertitle { + padding-bottom: 5px; + border-bottom-width: 1px; + border-bottom-style: solid; } -#advancedstuff a.dbx-toggle-open, #advancedstuff a.dbx-toggle-open:visited { - height: 22px; - width: 22px; - top: 3px; - right: 5px; - background-position: 0 -28px; -} +/* Global classes */ +.wp-hidden-children .wp-hidden-child { display: none; } +.wp-no-js-hidden { display: none; } +.ui-tabs-hide { display: none; } -#categorychecklist { - margin-right: 6px; +.commentlist .avatar { + vertical-align:text-top; } -/* additional clone styles */ -.dbx-clone { - opacity: 0.8; - -moz-opacity: 0.8; - -khtml-opacity: 0.8; - filter: alpha(opacity=80); +body.minwidth { + min-width: 808px; } -#newcat { - width: 120px; - margin-right: 5px; +ul.view-switch { + float: right; + list-style: none; + margin: -23px 5px -2px 0; + position: relative; } -input #catadd { - background: #a4a4a4; - border-bottom: 1px solid #898989; - border-left: 1px solid #bcbcbc; - border-right: 1px solid #898989; - border-top: 1px solid #bcbcbc; - color: #fff; - font-size: 10px; - padding: 0; +ul.view-switch li { + float: left; margin: 0; + font-size: 11px; + padding: 4px 6px; font-weight: bold; - height: 20px; - margin-bottom: 2px; - text-align: center; - width: 37px; } -#howto { - font-size: 11px; - margin: 0 5px; - display: block; +ul.view-switch a { + text-decoration: none; } -#jaxcat { - margin: 0; - padding: 0; +ul.view-switch li.current { + border: none; + -moz-border-radius-topleft: 3px; + -khtml-border-top-left-radius: 3px; + -webkit-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -khtml-border-top-right-radius: 3px; + -webkit-border-top-right-radius: 3px; + border-top-right-radius: 3px; } -#ajax-response.alignleft { - margin-left: 2em; + +#the-comment-list .comment a { + padding-bottom: 1px; + text-decoration: none; + border-bottom-width: 1px; + border-bottom-style: solid; } -#postdivrich #edButtons { - padding-left: 3px; + +#the-comment-list td.comment p.comment-author { + margin-top: 0; + margin-left: 0 ; } -#postdivrich #content, #postdivrich #content:active { - border: 1px solid #ccc; +#the-comment-list p.comment-author img { + float: left; + margin-right: 8px; } -#edButtons input, #edButtons input:active { - margin: 0 2px -1px; +#the-comment-list p.comment-author strong a { + border: none; } -#edButtons input.edButtonFore, #edButtons input.edButtonFore:active { - background: #f0f0ee; - border-bottom: 1px solid #f0f0ee; +#the-comment-list td { + vertical-align: top; } -#edButtons input.edButtonBack, #edButtons input.edButtonBack:active { - background: #fff url( images/fade-butt.png ) repeat-x 0 15px; - border-bottom: 1px solid #ccc; +#the-comment-list td.comment { + width: 65%; + max-width: 460px; + word-wrap: break-word; } -.page-numbers { - padding: 4px 7px; - border: 1px solid #fff; - margin-right: 3px; +#the-comment-list td.comment p { + margin-left: 8px; } -a.page-numbers { - border: 1px solid #ccc; +#the-comment-list .check-column { + padding-top: 8px; } -a.page-numbers:hover { - border: 1px solid #999; +#templateside ul li a { + text-decoration: none; } -.page-numbers.current { - border: 1px solid #999; - font-weight: bold; +.curtime { + background-image: url(images/date-button.gif); + background-repeat: no-repeat; + background-position: left 2px; + padding-left: 18px; } -.pagenav span { - font-weight: bold; - margin: 0 6px; +.tablenav .delete { + margin-right: 20px; } -a.view-link { +#tTips { + display: none; position: absolute; - right: 5%; - margin-right: 220px; - text-decoration:underline; + margin: 0; + padding: 0 0 8px 0; + background-image: url(images/tail.gif); + background-repeat: no-repeat; + background-position: 15px bottom; + background-color: thansparent; } -#update-nag, .plugin-update { - border-bottom: 1px solid #ccc; - border-top: 1px solid #ccc; - background: #fffeeb; - line-height: 29px; - font-size: 12px; - color: #555; +#tTips p#tTips_inside { + margin: 0; + padding: 8px 12px; text-align: center; -} + -moz-border-radius: 8px; + -khtml-border-radius: 8px; + -webkit-border-radius: 8px; + border-radius: 8px; +} -#update-nag a, .plugin-update a { - font-size: 1.1em; +td.action-links, th.action-links { + text-align: right; } -#update-nag a:link, .plugin-update a:link { - color: #036; + +#poststuff h3, #poststuff .closed h3 { + cursor: pointer; +} + +.hide-if-no-js { + display: none; } |
